Let's suppose that I used an Application.LoadLevelAdditive() instruction to load a "Menu Scene" over my main game scene, just to allow the user to do in game adjustments to his preferences.
When a "Resume Game" is clicked the menu scene should be removed and the game should go on.
While the problem keeps that simple I can just manually remove the component created to render the menu, but let's suppose that for some reason I had to load a huge scene over another, and now I need to clear ONLY the objects belonging to a specific scene.
How do I do that?
I tried answering myselft with some possibilities:
1) Saving scene data somewhere and then reload it (deleting everything) and restoring data?
2) Flagging somehow (how?) all specific scene objects so I can delete them all?
3) Calling a magic method deleteLevel() which I don't know if exists? ^^
Is any of those a best solution?
Is there something else I should know?
Thanks in advance for the answers!
asked Apr 12 '11 at 08:46 AM
Interesting questions! willing to know now :). I never formulate that question consciously and just assumed I had to roll my own system.
To answer question 2: What I do is put a specific component that manage such meta data and query that instead of relying on some built in feature. This allow me for more flexibility obviously and it can change at runtime as well (say an object becomes part of the current contact and must not be destroy now).
The system I have in place has a main application with the navigation system and other fancyness that ARE always present throughout the game. All its content is set to not be destroyed on level load. Then, when I need to load a new level, I simply load that main application again, and then load the level in question, which effectively removes all GO that should be destroyed on level load. It might not fit your purpose as is, but could be a starting point. You can do this with loading an empty level as well ( never tried).
Hope that make sense.
answered Apr 12 '11 at 09:17 AM