码迷,mamicode.com
首页 > 其他好文 > 详细

MonoBehaviour.StopCoroutine

时间:2014-11-27 14:19:43      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   io   ar   color   sp   for   on   

MonoBehaviour.StopCoroutine

Description

Stops all coroutines named methodName running on this behaviour.

Please note that only StartCoroutine using a string method name can be stopped using StopCoroutine

 

自己试验了一下,发现参数需要一一对应

 1 public class MyTest2 : MonoBehaviour
 2 {
 3     IEnumerator curTask;
 4     void OnGUI()
 5     {
 6         if (GUI.Button(new Rect(10, 10, 150, 100), "start")) {
 7             curTask = DealWithForward();
 8             //Please note that only StartCoroutine using IEnumerator 
 9             //can be stopped using StopCoroutine using IEnumerator.
10             StartCoroutine(curTask);
11 
12             //Please note that only StartCoroutine using a string method name 
13             //can be stopped using StopCoroutine using a string method name .
14             //StartCoroutine("DealWithForward");
15         }
16             
17         if (GUI.Button(new Rect(10, 110, 150, 100), "stop"))
18             SotpAnimation();
19     }
20     
21 
22 
23     public IEnumerator DealWithForward()
24     {
25         while (true)
26         {
27             Debug.Log(" 展示 问题 需要 土拨鼠 动画  Time.realtimeSinceStartup :" + Time.realtimeSinceStartup);
28             
29             yield return new WaitForSeconds(3.0f);
30         }
31     }
32 
33     public void SotpAnimation()
34     {
35         Debug.Log("如果 当前 有 土拨鼠 动画 停止");
36 
37         StopCoroutine(curTask);
38 
39         //StopCoroutine("DealWithForward");
40     }
41 }

 

 

 
 

MonoBehaviour.StopCoroutine

标签:des   style   blog   io   ar   color   sp   for   on   

原文地址:http://www.cnblogs.com/chongxin/p/4126162.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!