- Home /
Unity Crashes with too many prefabs
Hello,
I am developing a game in unity which involves me making a terrain out of blocks and other objects, however if I ever make the game over around 500x500 which involves instansiating around 250,000 prefabs Unity crashes. If I do 500x500 and instansiate different prefabs in a differnt loop directly after this it works fine.
Is there anyway to stop this from happening or is there a limit to the number of prefabs?
Thanks,
Adam
Are you instantiating all of these through scripting? If you are, that would cause the crash, and you may want some of these objects put into the scene manually.
I am because the terrain is randomly generated at game load so there was no option to put them in manually.
Are you storing the prefabs in memory, like adding them into an array? $$anonymous$$ight be memory related. Can you see all the prefabs at a given time? You might want to remove prefabs as you go to keep it clean
I suggest you have the $$anonymous$$i map look at something else that's smaller - that's going to be a lot of drawing for a map - potentially very slow. As you are procedurally creating your world could you also procedurally create something for the $$anonymous$$imap?
Right I think I have solved the problem with the $$anonymous$$imap. I have created another scene which has a terrain (fixed size), I will then instansiate cubes to act as the models (to scale). Then positioned a camera directly looking down on it and set the Y value to be negative so the terrain will be underneath everything else. I then load the $$anonymous$$imap scene by using Application.LoadLevelAdditive. This means I will have exactly what I wanted a 3d landscape which will render as required and a low resolution 2d $$anonymous$$imap.
Your answer

Follow this Question
Related Questions
A node in a childnode? 1 Answer
Prefabs Empty After Crash 2 Answers
Installing Unity 3D 4.3.4 on Windows 8.1 2 Answers
Crash app unity 4.5.5f1 on nexus 7 (Android 4.4.4) 0 Answers
Instantiate prefab 1 Answer