Last active
August 29, 2015 14:03
-
-
Save vrobel/6120c07f1c57b29cc770 to your computer and use it in GitHub Desktop.
Multiple SceneManagers in one Scene
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
//All SceneManagers that I want to keep in one scene needs te extend this class. | |
//I had to fix it in designer generated code which is poor, or it can be copy pasted to each Scene class. | |
//Add all root GameObjects for each scene so they will get enabled when scene is activated | |
public class CoexistiveSceneManager : SceneManager | |
{ | |
public List<GameObject> SceneRoots; | |
public override void Setup() | |
{ | |
base.Setup(); | |
SetSceneRoots(false); | |
} | |
public override void OnLoaded() | |
{ | |
base.OnLoaded(); | |
SetSceneRoots(true); | |
} | |
public override void Unload() | |
{ | |
base.Unload(); | |
SetSceneRoots(false); | |
} | |
private void SetSceneRoots(bool value) | |
{ | |
foreach (var sceneRoot in SceneRoots) | |
{ | |
sceneRoot.SetActive(value); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LevelSelectScene : LevelSelectSceneBase { | |
public override System.Collections.IEnumerator Load(UpdateProgressDelegate progress) { | |
// Use the controllers to create the game. | |
yield break; | |
} | |
public override void Setup() { | |
base.Setup(); | |
} | |
// Replaced autogenerated commands from SwitchGameAndLevel to SwitchGame. | |
public override void Back() | |
{ | |
GameManager.SwitchGame<PackSelectScene>((container) => { container._PackSelectSceneSettings = _BackTransition; }); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.dropbox.com/s/ngwojkkbyde6k47/SceneManager%20design.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment