Game Over Scene Efficient?
Is it more efficient to have a whole scene dedicated to the "Game Over" whenever two colliders hit each other? Or is it better to have a transparent UI Image become visible after they collide and everything else is disabled?
Answer by TBruce · Jun 16, 2016 at 01:36 AM
Personally I prefer not to use a separate scene. I create a prefab of my GameOver scene and instantiate it when needed.
That is a smart idea! So I would actually make the "Game Over" in another scene, but I would not use Application.LoadLevel to load the scene. Ins$$anonymous$$d I would just Instantiate and Destroy when needed? Or Enable and Disable? Am I correct? :) @$$anonymous$$avina
You would create your "Game Over" panel which would be attached to a canvas. Create a script file to handle everything including any/all button functions (e.g. CancelButton(), LoadNextLevelButton()...).
I attach the script to the canvas. I set up the button events. Then save the canvas as a prefab (Note: If this is the only canvas in the scene then you will want to make the EventSystem GameObject a child of the "Game Over" canvas).
When needed I instantiate the prefab.
Another thing I do some of the times (usually for customization) is I bring the prefab into each scene and I set it as inactive and the activate it when needed.
I also use both methods for end of level screens.
Okay! So actually what you said is very similar to the "Game Over" in the Survival Shooter tutorial provided by the Unity Team. In this method, my "GameOver" would be in the same scene as the "$$anonymous$$ain Gameplay" scene, but you would not see anything regarding the "Game Over" and "Retry", "Go Back To $$anonymous$$enu", etc. buttons until you die?
Answer by JatsArts · Jun 16, 2016 at 12:41 PM
I would keep it in another scene. But pre-load it beforehand so I can show it quickly. Having to toggle the visiblity every time you edit is too much hassle and too expensive to maintain.
Okay cool. Any tutorials you know of that can guide me towards this "pre-loading" term you used? @JatsArts