diff --git a/Custom/CustomMapManager.cs b/Custom/CustomMapManager.cs index 859f80f2..6b6b27c3 100644 --- a/Custom/CustomMapManager.cs +++ b/Custom/CustomMapManager.cs @@ -72,7 +72,7 @@ public void AddScene( customMap map){ zone.scenes.Add(map.sceneName,map); Zones.Add(zone.ZoneName,zone); } - GameManager.instance.StartCoroutine(generateCustomMap(map)); + CoroutineHelper.GetRunner().StartCoroutine(generateCustomMap(map)); } public void Remove(string sceneName){ diff --git a/Custom/CustomShinyManager.cs b/Custom/CustomShinyManager.cs index ca743170..9d4b20bc 100644 --- a/Custom/CustomShinyManager.cs +++ b/Custom/CustomShinyManager.cs @@ -34,7 +34,7 @@ public IEnumerator SpawnCoro(Scene scene){ } public void SpawnOnSceneLoad(Scene oldScene, Scene newScene) { - GameManager.instance.StartCoroutine(SpawnCoro(newScene)); + CoroutineHelper.GetRunner().StartCoroutine(SpawnCoro(newScene)); } public string LanguageGet( string key, string sheet, string orig){ if(sheet == $"{languageKey}UI" && key.StartsWith(languageKey)){ diff --git a/Satchel.csproj b/Satchel.csproj index 95811b24..cdbd685c 100644 --- a/Satchel.csproj +++ b/Satchel.csproj @@ -130,6 +130,7 @@ + diff --git a/Utils/AnimationUtils.cs b/Utils/AnimationUtils.cs index 24cecaae..c6c414b2 100644 --- a/Utils/AnimationUtils.cs +++ b/Utils/AnimationUtils.cs @@ -96,7 +96,7 @@ public static IEnumerator playAllAnim(this GameObject go,int i = 0) { spriteAnimator.PlayFromFrame(clips[i], 0); Log(clips[i].name); yield return new WaitForSeconds(2f); - GameManager.instance.StartCoroutine(go.playAllAnim(i)); + CoroutineHelper.GetRunner().StartCoroutine(go.playAllAnim(i)); } } diff --git a/Utils/AssemblyUtils.cs b/Utils/AssemblyUtils.cs index 1f42161d..fd77a62a 100644 --- a/Utils/AssemblyUtils.cs +++ b/Utils/AssemblyUtils.cs @@ -6,7 +6,7 @@ namespace Satchel { public static class AssemblyUtils{ public static string name = "Satchel"; - public static string ver = "0.8.0"; + public static string ver = "0.8.1"; public static string Version(){ var verStr = $"{name} v{ver}"; return verStr; diff --git a/Utils/CoroutineHelper.cs b/Utils/CoroutineHelper.cs new file mode 100644 index 00000000..0cf90304 --- /dev/null +++ b/Utils/CoroutineHelper.cs @@ -0,0 +1,18 @@ +namespace Satchel +{ + public class CoroutineRunner : MonoBehaviour{} + public static class CoroutineHelper{ + private static GameObject gameObject; + private static CoroutineRunner runner; + public static CoroutineRunner GetRunner(){ + if(runner == null){ + if(gameObject == null){ + gameObject = new GameObject(); + GameObject.DontDestroyOnLoad(gameObject); + } + runner = gameObject.GetAddComponent(); + } + return runner; + } + } +} \ No newline at end of file