10秒後にwhile文を止めたいので、下のスクリプトを書いたところ、while文が初めから実行されません。
エラーなどは出ていません。
ご教授願います。
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class Create : MonoBehaviour { 6 private float time = 10; //初期値は10,10秒後に"Create()"の実行を止めたい 7 Rigidbody2D rb; 8 9 void Start () { 10 rb = GetComponent<Rigidbody2D>(); 11 StartCoroutine(Create()); 12 } 13 14 void Update (){ 15 time -= Time.deltaTime; //1秒に1減らしていく 16 } 17 18 IEnumerator Create() { 19 while (time < 0) { 20 //timeが0になるまで実行したい 21 } 22 } 23} 24
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。