浏览代码

Added initializationLoader class

/main
Amel Negra 4 年前
当前提交
ee385f08
共有 2 个文件被更改,包括 51 次插入0 次删除
  1. 40
      UOP1_Project/Assets/Scripts/SceneManagement/InitializationLoader.cs
  2. 11
      UOP1_Project/Assets/Scripts/SceneManagement/InitializationLoader.cs.meta

40
UOP1_Project/Assets/Scripts/SceneManagement/InitializationLoader.cs


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);
}
}

11
UOP1_Project/Assets/Scripts/SceneManagement/InitializationLoader.cs.meta


fileFormatVersion: 2
guid: 43bf3a70578af0044a7af79dd1c44ea6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存