[Unity] GameObject에서 StartCoroutine 사용하기

in #unity7 years ago
  public static Coroutine StartCoroutine(this GameObject go, IEnumerator routine)
  {
      MonoBehaviour mono = go.GetComponent<MonoBehaviour>();
      if (null == mono)
          mono = go.AddComponent<MonoBehaviour>();

      return mono.StartCoroutine(routine);
  }

  public static void StopCoroutines(this GameObject go, IEnumerator routine)
  {
      MonoBehaviour mono = go.GetComponent<MonoBehaviour>();
      if (null == mono)
          mono = go.AddComponent<MonoBehaviour>();

      mono.StopCoroutine(routine);
  }

  public static void StopCoroutines(this GameObject go, string methodName)
  {
      MonoBehaviour mono = go.GetComponent<MonoBehaviour>();
      if (null == mono)
          mono = go.AddComponent<MonoBehaviour>();

      mono.StopCoroutine(methodName);
  }

  public static void StopAllCoroutines(this GameObject go)
  {
      MonoBehaviour mono = go.GetComponent<MonoBehaviour>();
      if (null == mono)
          mono = go.AddComponent<MonoBehaviour>();

      mono.StopAllCoroutines();
  }
Sort:  

Great Post! Get Free Upvotes ! http://ity.im/CHE7E

Congratulations @pangcola! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got a First Vote

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why here!

Coin Marketplace

STEEM 0.13
TRX 0.34
JST 0.035
BTC 108074.45
ETH 4399.12
USDT 1.00
SBD 0.83