|
|
|
|
|
|
|
|
|
|
public class LocationLoader : MonoBehaviour |
|
|
|
{ |
|
|
|
public GameScene[] mainMenuScenes; |
|
|
|
[Header("Initialization Scene")] |
|
|
|
public GameSceneSO initializationScene; |
|
|
|
[Header("Load on start")] |
|
|
|
public GameSceneSO[] mainMenuScenes; |
|
|
|
[Header("Loading Screen")] |
|
|
|
public GameObject loadingInterface; |
|
|
|
public Image loadingProgressBar; |
|
|
|
|
|
|
//List of scenes to unload
|
|
|
|
private List<Scene> _ScenesToUnload = new List<Scene>(); |
|
|
|
//Keep track of the scene we want to set as active (for lighting/skybox)
|
|
|
|
private GameScene _activeScene; |
|
|
|
private GameSceneSO _activeScene; |
|
|
|
|
|
|
|
private void OnEnable() |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
private void Start() |
|
|
|
{ |
|
|
|
if(SceneManager.GetActiveScene().name == "ScenesLoader") |
|
|
|
if(SceneManager.GetActiveScene().name == initializationScene.sceneName) |
|
|
|
{ |
|
|
|
LoadMainMenu(); |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> This function loads the scenes passed as array parameter </summary>
|
|
|
|
public void LoadScenes(GameScene[] locationsToLoad, bool showLoadingScreen) |
|
|
|
public void LoadScenes(GameSceneSO[] locationsToLoad, bool showLoadingScreen) |
|
|
|
{ |
|
|
|
//Add all current open scenes to unload list
|
|
|
|
AddScenesToUnload(); |
|
|
|
|
|
|
} |
|
|
|
public void AddScenesToUnload() |
|
|
|
{ |
|
|
|
if (SceneManager.sceneCount > 0) |
|
|
|
for (int i = 0; i < SceneManager.sceneCount; ++i) |
|
|
|
for (int i = 0; i < SceneManager.sceneCount; ++i) |
|
|
|
Scene scene = SceneManager.GetSceneAt(i); |
|
|
|
if (scene.name != initializationScene.sceneName) |
|
|
|
Scene scene = SceneManager.GetSceneAt(i); |
|
|
|
if (scene.name != "ScenesLoader") |
|
|
|
{ |
|
|
|
Debug.Log("Added scene to unload = " + scene.name); |
|
|
|
//Add the scene to the list of the scenes to unload
|
|
|
|
_ScenesToUnload.Add(scene); |
|
|
|
} |
|
|
|
Debug.Log("Added scene to unload = " + scene.name); |
|
|
|
//Add the scene to the list of the scenes to unload
|
|
|
|
_ScenesToUnload.Add(scene); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
public bool CheckLoadState(String sceneName) |
|
|
|
{ |
|
|
|
if (SceneManager.sceneCount > 0) |
|
|
|
for (int i = 0; i < SceneManager.sceneCount; ++i) |
|
|
|
for (int i = 0; i < SceneManager.sceneCount; ++i) |
|
|
|
Scene scene = SceneManager.GetSceneAt(i); |
|
|
|
if (scene.name == sceneName) |
|
|
|
Scene scene = SceneManager.GetSceneAt(i); |
|
|
|
if (scene.name == sceneName) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|