UnityでC#を使って作っています。
コールチンを使ってsound Play();を30秒ごとに実行させたいのですが、StartCoroutine(Sleep));からIEnumerator Sleep()に移行しません。
そのためにaddText textの表示が 1 、30秒後に 2 を表示したいのですが、すぐに 2 を表示してしまいます。
また、このスクリプトで 1 、30秒後に 2 を表示出来るのかも分からないので訂正箇所を教えてもらえますか。
下記にそのスクリプトを添えて置きます。
・・・・
void Update()
{
ST = GameObject.Find("Stage");
scripta1 = ST.GetComponent<Stage2>();
T = scripta1.total;
if (Input.anyKey)
{
if (T < 0)
StartCoroutine(Sleep());
{ addText.text = " " + 1.ToString(); sound.PlayWide(); Debug.Log("add"); } if (T < 1) StartCoroutine(Sleep()); { addText.text = " " + 2.ToString(); sound.PlayWide(); Debug.Log("add"); } } } IEnumerator Sleep() { yield return new WaitForSeconds(30.f); }
}
*T=5と考えてください。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/15 06:33
2017/11/15 07:39 編集
2017/11/18 14:58
2017/11/20 03:51 編集