|
|
|
|
|
|
using UnityEngine.SceneManagement; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// This script loads the initial Scene, to allow to start the game from any gameplay Scene
|
|
|
|
/// This script loads the persistent managers and gameplay Scenes, to allow to start the game from any gameplay Scene
|
|
|
|
/// It can also be used for menu scene by just adding the persistent managers scene on the inspector
|
|
|
|
public GameSceneSO initializationScene; |
|
|
|
public GameSceneSO[] persistentScenes; |
|
|
|
private void Awake() |
|
|
|
private void Start() |
|
|
|
{ |
|
|
|
Application.targetFrameRate = targetFramerate; // For debugging purposes
|
|
|
|
|
|
|
|
|
|
|
if (scene.path == initializationScene.scenePath) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
for (int j = 0; j < persistentScenes.Length; ++j) |
|
|
|
if (scene.path == persistentScenes[j].scenePath) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
SceneManager.LoadSceneAsync(persistentScenes[j].scenePath, LoadSceneMode.Additive); |
|
|
|
} |
|
|
|
SceneManager.LoadSceneAsync(initializationScene.scenePath, LoadSceneMode.Additive); |
|
|
|
} |
|
|
|
#endif
|
|
|
|
} |