現状
現在オブジェクトを一定時間ごとにスポーンさせるスクリプトを作っています。そこでコルーチンを使ったのですが、なぜか前使っていたのと同じ方法でやっても動きません。
問題の箇所
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class TextSpawn : MonoBehaviour { 6 static public float TextSpawnWaitSecond = 1; 7 public GameObject TextTarget; 8 9 // Use this for initialization 10 void Start () { 11 StartCoroutine("Spawn"); 12 StartCoroutine("debug"); 13 } 14 15 // Update is called once per frame 16 void Update () { 17 18 } 19 20 private IEnumerable Spawn() 21 { 22 GameObject Prefab = Instantiate(TextTarget, new Vector2(Random.Range(-960f, 960f), 0), Quaternion.identity) as GameObject; 23 Prefab.transform.SetParent(GameObject.Find("Canvas").gameObject.transform); 24 Debug.Log("call"); 25 while (true) 26 { 27 yield return new WaitForSeconds(TextSpawnWaitSecond); 28 } 29 } 30 IEnumerable debug() 31 { 32 Debug.Log("call"); 33 yield return null; 34 } 35}
コルーチンもいくつか作ってテストしてみたのですが。
呼び出すことができません。
何がいけないのか是非教えてください。
環境
VisualStudio2017
Unity2018

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/21 05:06
2018/08/21 05:30
2018/08/21 05:31