[Unity] GameObject에서 StartCoroutine 사용하기

in unity •  7 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();
  }
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  ·  7 years ago Reveal Comment

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!

WARNING - The message you received from @riandifc is a CONFIRMED SCAM!
DO NOT FOLLOW any instruction and DO NOT CLICK on any link in the comment!
For more information, read this post: https://steemit.com/steemit/@arcange/phishing-site-reported-autosteem-dot-info
Please consider to upvote this warning or to vote for my witness if you find my work to protect you and the community valuable. Your support is really appreciated!