forked from Shardstone/trail-into-darkness
First commit on my server, yey!
This commit is contained in:
42
Assets/Code/Core/Boot.cs
Normal file
42
Assets/Code/Core/Boot.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Nox.EditorCode;
|
||||
using System;
|
||||
using Unity.VectorGraphics;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Nox.Core {
|
||||
public class Boot {
|
||||
/// <summary>
|
||||
/// The is the first method called when the game starts. It will load the Initializer prefab which will initialize the project
|
||||
/// </summary>
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
private static void Initialize() {
|
||||
#if UNITY_EDITOR
|
||||
switch(BootMode.BootType) {
|
||||
case BootType.UnityDefault:
|
||||
return;
|
||||
case BootType.SceneBoot:
|
||||
Addressables.InstantiateAsync("Initializer").WaitForCompletion();
|
||||
break;
|
||||
case BootType.FullBoot:
|
||||
var loadOperation = SceneManager.LoadSceneAsync("Startup", LoadSceneMode.Single);
|
||||
if(loadOperation != null) {
|
||||
loadOperation.completed += OnCompleted;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
#else
|
||||
Addressables.InstantiateAsync("Initializer").WaitForCompletion();
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void OnCompleted(AsyncOperation obj) {
|
||||
obj.allowSceneActivation = true;
|
||||
Addressables.InstantiateAsync("Initializer").WaitForCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user