您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
40 行
1.1 KiB
40 行
1.1 KiB
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
/// <summary>
|
|
/// This class is responsible for starting the game by loading the persistent managers scene
|
|
/// and raising the event to load the Main Menu
|
|
/// </summary>
|
|
|
|
public class InitializationLoader : MonoBehaviour
|
|
{
|
|
[Header("Persistent managers Scene")]
|
|
[SerializeField] private GameSceneSO _PersistentManagersScene = default;
|
|
|
|
[Header("Loading settings")]
|
|
[SerializeField] private GameSceneSO[] _MenuToLoad = default;
|
|
[SerializeField] private bool _showLoadScreen = default;
|
|
|
|
[Header("Broadcasting on")]
|
|
[SerializeField] private LoadEventChannelSO _MenuLoadChannel = default;
|
|
|
|
void Start()
|
|
{
|
|
//Load the persistent managers scene
|
|
StartCoroutine(loadScene(_PersistentManagersScene.scenePath));
|
|
}
|
|
|
|
IEnumerator loadScene(string scenePath)
|
|
{
|
|
AsyncOperation loadingSceneAsyncOp = SceneManager.LoadSceneAsync(scenePath, LoadSceneMode.Additive);
|
|
|
|
//Wait until we are done loading the scene
|
|
while (!loadingSceneAsyncOp.isDone)
|
|
{
|
|
yield return null;
|
|
}
|
|
//Raise the event to load the main menu
|
|
_MenuLoadChannel.RaiseEvent(_MenuToLoad, _showLoadScreen);
|
|
}
|
|
}
|