- Home /
Many objects slow down Unity Scene View
I'm making a strategy game similar to Hearts of Iron or Europa Universalis. The map is split up into provinces, each province is created by procedural generation where the app reads a Color map of the world, and then generates meshes for each province.
When each province's mesh is created, it Instantiates a "Province" prefab and adds the Mesh to it. Each province and mesh becomes its own game object. The reason I do this is because I want each province to have its own attributes and functions.
In the end game, I want to be able to have 750 - 1200 provinces. But currently even with only ~150 provinces or so, my Unity becomes incredibly slow and if I select a Mesh in Scene View, it takes many seconds before the mesh actually get selected. Sometimes Unity crashes.
It seems as if it's mostly the Unity Application, Scene View and Inspector that gets slow. Not the game itself within the "Game" window. The game have good framerate.
So... What am I doing wrong? Is it bad practise to have many Game Objects in Unity? Is it because I do Procedural Generation and for that reason everything is kept in Memory or something like that?
Answer by FortisVenaliter · May 05, 2016 at 07:02 PM
Well, two things to try:
Try building the game. Is the slowdown still present? If not, then there's no problem ^^
Otherwise, try opening the profiler window and see what it is that's actually causing the slowdown, then address the issue specifically.
Both your advice is how to make the compiled, rendered GA$$anonymous$$E faster. However I specifically state that there's nothing wrong with the performance of the game itself. The problem is the Unity Editor, Scene View and so on that becomes super slow.
Profiler only show the data used in the rendered Game view from what I know.
The game has about 130+ FPS. No issues. But I can't work with the game if Unity crashes, or Unity takes 5-10 seconds to select an object.
Profiling while running in the editor will show you the resources used and ti$$anonymous$$gs of different functions when running in the editor, but won't help explain why scene view is slow.
1200 game objects is not in itself a problem, but it's what those game objects are doing - how complex their meshes/materials are etc. Do you have any scripts set to [ExecuteInEdit$$anonymous$$ode] ? Please give us more information about your scene, or any details given in the crash report.
Answer by NightAvail · May 06, 2016 at 09:08 AM
My advice, don't use the editor at all... It's kinda useless for the type of game you're trying to create. In fact, the editor is not meant for dynamic content. Here are also some steps I had to take to achieve being able to load in any CK2 map without issues
http://forum.unity3d.com/threads/godus-like-procedural-terrain-generation.395034/#post-2578929
I should clarify this too. You'd of course like to use the editor for assets from the store you may purchase, or for testing out your heightmap/shaders, I just don't think it would be helpful for the dynamic (not static) generation process of the provinces. Of course, that's just my opinion. :)
Your answer
Follow this Question
Related Questions
How to create voxel-based procedural terrain 1 Answer
DOTS Grid-based generation question. 1 Answer
Procedural Mesh From Random List Of Veritces 2 Answers
How to fill out a procedurally generated mesh with quads of varying sizes? 0 Answers
How to render procedurally generated mesh to be rendered as 2 sided? 1 Answer