【3Dゲームエンジン】Unity質問スレッド34at GAMEDEV
【3Dゲームエンジン】Unity質問スレッド34 - 暇つぶし2ch37:名前は開発中のものです。
18/02/12 13:21:24.96 2m1iD4au.net
コルーチンの停止について質問させてください。
以下のコードのようにクリックしたらtestCoroutineを止めるというのをやりたいのですが、
testCoroutineだけでなくStart()の中のコルーチンもなぜか止まってしまいます。
(実際にコンソールに"startCoroutine"が表示されない)
testCoroutineのみを止めるにはどうすればよいでしょうか?
public class CoroutineTest : MonoBehaviour {
IEnumerator testCoroutine;
IEnumerator Start() {
while (true){
testCoroutine = TestCoroutine();
yield return StartCoroutine(testCoroutine);
Debug.Log("startCoroutine");
yield return null;
}
}
void Update () {if(クリックしたら) StopCoroutine(testCoroutine);}
IEnumerator TestCoroutine(){
while (true){
Debug.Log("testCoroutine");
yield return null;
}
}
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch