Create a big graph in Unity
Hi, I have a task to achieve and I am having some problems with the performance.
I have to make a graph (by graph I mean nodes and edges) to be drawn on Unity so that I can move over it to see it. The edges and the nodes are both 2d.
I have an Xml where I read all the information of the graph. The xml can contain the following elements:
< circle cx="19.818" cy="-8.4833" color="rgb(148,36,179)" radius="0.0497241" />
< line x1="21.5083" x2="18.157" y1="-1.4545" y2="-1.22787" color="rgb(89,89,0)" width="0.00994481" />
So, as soon as the unity program loads, I read this xml and parse it to create the nodes and edges. I have a prefab of a node and a prefab of a line. This ones are made by creating an empty object and using unity to draw them.
So I only have two types of prefabs: nodes and lines.
As soon as I go parsing the xml, I go creating a new instance of the prefab depending if it is a line or a circle. This part is working perfect and the graph is drawing perfect and I can move around it to see it.
The problem that I have is that the graphs are HUGE. I have a medium graph and it has 50000 nodes and 110000 lines. So, in total we have 160000 objects. When we are seeing only a part of the graph on the camera it works fine, but when I make a zoom out and I see the whole graph I get lag. And this is a medium graph, I can have graphs that are even bigger than this one.
So my question is, is there a way to solve the problem of the lag when I see the whole graph? Or with so many items in Unity is impossible? Although there are so many items, they are very simple items.
Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220612083818im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Gfx.WaitForPresent rant, and editor fix 0 Answers
Lags while camera movement (gfx.waitforpresent) 0 Answers
Movie texture lagging 1 Answer