| | 1 | | using System.Collections; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | public class CoroutineStarter : MonoBehaviour |
| | 5 | | { |
| | 6 | | private static CoroutineStarter instanceValue; |
| | 7 | |
|
| | 8 | | public static CoroutineStarter instance |
| | 9 | | { |
| | 10 | | get |
| | 11 | | { |
| 6612 | 12 | | if (instanceValue == null) |
| | 13 | | { |
| 636 | 14 | | instanceValue = new GameObject("_CoroutineStarter").AddComponent<CoroutineStarter>(); |
| | 15 | | } |
| | 16 | |
|
| 6612 | 17 | | return instanceValue; |
| | 18 | | } |
| | 19 | | } |
| | 20 | |
|
| 4728 | 21 | | public static Coroutine Start(IEnumerator function) { return instance.StartCoroutine(function); } |
| | 22 | |
|
| | 23 | | public static void Stop(Coroutine coroutine) |
| | 24 | | { |
| 1861 | 25 | | if (instanceValue != null && coroutine != null) |
| 1776 | 26 | | instance.StopCoroutine(coroutine); |
| 1861 | 27 | | } |
| | 28 | |
|
| | 29 | | } |