Skip to content

Commit

Permalink
add coroutine helper and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
PrashantMohta committed May 3, 2022
1 parent 7b639b6 commit 9f70317
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Custom/CustomMapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion Custom/CustomShinyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down
1 change: 1 addition & 0 deletions Satchel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<Compile Include="Utils\SpriteUtils.cs" />
<Compile Include="Utils\TextureUtils.cs" />
<Compile Include="Utils\WavUtils.cs" />
<Compile Include="Utils\CoroutineHelper.cs" />

<Compile Include="Monobehaviour\Unity\AlertRangeMarker.cs" />
<Compile Include="Monobehaviour\Unity\ChangeMeshColor.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Utils/AnimationUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

}
Expand Down
2 changes: 1 addition & 1 deletion Utils/AssemblyUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions Utils/CoroutineHelper.cs
Original file line number Diff line number Diff line change
@@ -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<CoroutineRunner>();
}
return runner;
}
}
}

0 comments on commit 9f70317

Please sign in to comment.