- Home /
Persistent game objects
Hello everyone!
Im trying to have a static class to store Game Objects (all the info inside them) through all the program (and use them wherever i want).
The problem is: I have scene A (where game objects are shown into the scene). Scene B where i select the game objects to show into A. The transitions could be a loop (A -> B ->A ->B...). When i went back from B to A, the Game Objects created at the first "iteration" are deleted by Unity and i only have the reference.
Can you help me with that?
Thanks in advance! :)
Answer by whydoidoit · Feb 19, 2014 at 10:23 AM
Call DontDestroyOnLoad on the gameObject when you add it to your class.
Hi whydoidoit, I tried with DontDestroyOnLoad but i couldnt "hide" the objects into the scene B. Finally i used an static class to store the Transform, $$anonymous$$aterial and Rotation of the Game Objects.
Then im restoring the objects when i come back from the scene B to A.
Thanks for the answer!