using System.Collections;
using UnityEngine;
namespace Funique
{
///
/// Library code does not inherits
/// Which means these class does not have way to access feature that unity provide
/// To improve this problem, We add a singleton monoBehaviour script to do all work
/// ------------------------------------------------
/// 程式庫的代碼並非繼承
/// 這代表這些類別無法存取 Unity 的執行 協程函式
/// 解決這個問題, 在場景加入一個獨立靜態物件來運行所有 函式
///
public class CoroutineHelper : MonoBehaviour
{
public static CoroutineHelper Instance;
private void Awake() { Instance = this; }
///
/// Start running a coroutine method
/// ------------------------------------------------
/// 開始協程
///
///
///
public Coroutine Run(IEnumerator method)
{
return StartCoroutine(method);
}
///
/// Stop a coroutine
/// ------------------------------------------------
/// 殺死協程
///
/// Target coroutine
public void Stop(Coroutine method)
{
StopCoroutine(method);
}
///
/// Stop a coroutine by method
/// It will kill the first one
/// ------------------------------------------------
/// 根據函式停止協程
/// 會殺死第一個生成的並存活的
///
///
public void Stop(IEnumerator method)
{
StopCoroutine(method);
}
///
/// Kill all coroutines
/// ------------------------------------------------
/// 殺死所有協程
///
public void StopAll()
{
StopAllCoroutines();
}
}
}