2022-01-22 00:24:52 +00:00
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.Utilities
|
2021-09-06 22:04:15 +00:00
|
|
|
|
{
|
2022-01-21 00:35:36 +00:00
|
|
|
|
public class StartupSingleton<T> : SingletonComponent<T>
|
2021-09-06 22:04:15 +00:00
|
|
|
|
where T : StartupSingleton<T>
|
|
|
|
|
{
|
2022-01-22 00:24:52 +00:00
|
|
|
|
protected override void OnSingletonAwakeValidate()
|
|
|
|
|
{
|
|
|
|
|
Scene activeScene = SceneManager.GetActiveScene();
|
|
|
|
|
|
|
|
|
|
if (!activeScene.IsValid() || activeScene.buildIndex != 0)
|
|
|
|
|
throw new System.Exception("Startup singleton can only be initialized in startup scene");
|
|
|
|
|
}
|
2021-09-06 22:04:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|