这是第一个 Unity 开放项目的repo,是 Unity 和社区合作创建的一个小型开源游戏演示,第一款游戏是一款名为 Chop Chop 的动作冒险游戏。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

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