- Home /
How to handle Grid Boxes properly?
I’m working on a city building game with multiple grids.
I have every grid box as one game object with a sprite renderer - the problem is when i try to instantiate lots of grid boxes to show them to user, the game suffers jerks.
Because it is a very costly operation to instantiate or to show all the different grid boxes(Even with object pooling).
Attached image is of my grid system. Where color denotes which objects can be placed on particular color.
Is there any better way to show dynamic grid boxes than separate gameobjects with sprite renderers?
Answer by Immanuel-Scholz · Apr 20, 2016 at 10:32 AM
When you pool them correctly and don't use SetActive but just disable/enable the renderer, then a couple of hundred objects should be reasonable.
Also, try Unity 5.4 beta with dynamic batching and "Graphics Jobs (Experimental)" enabled in Edit/Preferences/Player.
Now if we are talking about several tens of thousand GameObjects then this ain't gonna fly. You might want to render the whole stuff in a shader or set the colors into a texture and render only one texture.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to find sprite at grid location? 1 Answer
Create a grid on a cube? 0 Answers