I know I am getting an out of memory error here but I just dont know why. I have 5 fairly complex models that are displayed with GUI. The main script stores the 5 models in an array list and only calls them one at a time when needed (like a product selection screen). I know its not the GUI textures because I can remove the models from the list array and it will build and run with no problems. But when I add the 4th and 5th models back into the array it crashes when the level is being loaded.
I want to know WHY it is doing this if the models are not loaded until they are being called from the list. ANY HELP would be VERY appreciated!
Jake
xCode 4
iOS 4.3 / iPod 4th Gen
Unity iPhone Pro
Anyone have a suggestion?
Are you sure it’s not loading the models when the level is loaded? It doesn’t matter if their active, visible, etc. Generating any new GameObjects will increase your memory usage. How are you loading the models? It it crashes when the level is loaded and you haven’t “selected” the model yet, that suggests to me that you are, in fact, loading the model into memory. Can you post a bit of your code?
Unless you’re loading the objects from the resources folder via Resources.Load(), everything in your scene (even references to prefabs in an array that have yet to be instantiated) are loaded as soon as the level is started.
Yeah thanks guys. I had a big DUH moment and was thinking in editor terms and not programmer terms…
If I place a “Prefab” into a public variable on my script, then that is just like assigning that variable a very large class thus taking up a ton of memory to store it into that variable.
Thanks for the responses!
Jake