Demo day booth
This commit is contained in:
committed by
Jelle De Geest
parent
5b4a3ec4e7
commit
fcd8acad1e
@@ -17,6 +17,16 @@ public class SystemController
|
||||
/// </summary>
|
||||
private Stack<int> sceneStack = new Stack<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Index of the previous loaded scene
|
||||
/// </summary>
|
||||
public int previousScene = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Index of the current loaded scene
|
||||
/// </summary>
|
||||
public int currentScene = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Get the instance loaded by the singleton
|
||||
/// </summary>
|
||||
@@ -27,7 +37,8 @@ public class SystemController
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new SystemController();
|
||||
instance.sceneStack.Push(SceneManager.GetActiveScene().buildIndex);
|
||||
instance.currentScene = SceneManager.GetActiveScene().buildIndex;
|
||||
instance.sceneStack.Push(instance.currentScene);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
@@ -38,7 +49,17 @@ public class SystemController
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
public void LoadNextScene(string scenePath)
|
||||
{
|
||||
LoadNextScene(SceneUtility.GetBuildIndexByScenePath(scenePath));
|
||||
LoadNextScene(SystemController.GetSceneIndex(scenePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the index of a given scene
|
||||
/// </summary>
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
/// <returns></returns>
|
||||
public static int GetSceneIndex(string scenePath)
|
||||
{
|
||||
return SceneUtility.GetBuildIndexByScenePath(scenePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -47,8 +68,11 @@ public class SystemController
|
||||
/// <param name="sceneIndex">Buildindex of the scene</param>
|
||||
public void LoadNextScene(int sceneIndex)
|
||||
{
|
||||
sceneStack.Push(sceneIndex);
|
||||
SceneManager.LoadScene(sceneIndex);
|
||||
previousScene = currentScene;
|
||||
currentScene = sceneIndex;
|
||||
|
||||
sceneStack.Push(currentScene);
|
||||
SceneManager.LoadScene(currentScene);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,7 +81,7 @@ public class SystemController
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
public void SwapScene(string scenePath)
|
||||
{
|
||||
SwapScene(SceneUtility.GetBuildIndexByScenePath(scenePath));
|
||||
SwapScene(SystemController.GetSceneIndex(scenePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -66,7 +90,7 @@ public class SystemController
|
||||
/// <param name="sceneIndex">Buildindex of the scene</param>
|
||||
public void SwapScene(int sceneIndex)
|
||||
{
|
||||
sceneStack.Pop();
|
||||
currentScene = sceneStack.Pop();
|
||||
LoadNextScene(sceneIndex);
|
||||
}
|
||||
|
||||
@@ -75,9 +99,8 @@ public class SystemController
|
||||
/// </summary>
|
||||
public void BackToPreviousScene()
|
||||
{
|
||||
sceneStack.Pop();
|
||||
|
||||
if (sceneStack.Count > 0) SceneManager.LoadScene(sceneStack.Peek());
|
||||
previousScene = sceneStack.Pop();
|
||||
if (sceneStack.Count > 0) SceneManager.LoadScene(currentScene = sceneStack.Peek());
|
||||
else Application.Quit();
|
||||
}
|
||||
|
||||
@@ -87,7 +110,7 @@ public class SystemController
|
||||
/// <param name="scenePath">Path of the scene</param>
|
||||
public void BackToScene(string scenePath)
|
||||
{
|
||||
BackToScene(SceneUtility.GetBuildIndexByScenePath(scenePath));
|
||||
BackToScene(SystemController.GetSceneIndex(scenePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -96,9 +119,10 @@ public class SystemController
|
||||
/// <param name="sceneIndex">Buildindex of the scene</param>
|
||||
public void BackToScene(int sceneIndex)
|
||||
{
|
||||
previousScene = currentScene;
|
||||
while (0 < sceneStack.Count && sceneStack.Peek() != sceneIndex) sceneStack.Pop();
|
||||
|
||||
if (sceneStack.Count > 0) SceneManager.LoadScene(sceneStack.Peek());
|
||||
if (sceneStack.Count > 0) SceneManager.LoadScene(currentScene = sceneStack.Peek());
|
||||
else Application.Quit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user