以下のコードで問題があります。それが何をしているのかは、一つの道筋を構成します。C#IEnumeratorは変更不可
currentLength = Random.Range(maxFloorLength - 2, maxFloorLength);
List<GameObject> tempList = new List<GameObject>();
for (int i = 0; i < currentLength; ++i)
{
foreach (GameObject g in pooledFloor)
{
if (!g.activeInHierarchy)
{
g.SetActive(true);
g.transform.position = startPoint + buildDirection * i;
g.transform.DOScaleY(5, 0.25f).Play();
lastFloorPositions.Add(g.transform.position);
tempList.Add(g);
break;
}
}
yield return new WaitForSeconds(0.05f);
}
これは私がこれを変更するとき、期待通りに動作しますが:
currentLength = Random.Range(maxFloorLength - 2, maxFloorLength);
List<GameObject> tempList = new List<GameObject>();
for (int i = 0; i < currentLength; ++i)
{
foreach (GameObject g in pooledFloor)
{
if (!g.activeInHierarchy)
{
g.transform.position = startPoint + buildDirection * i;
lastFloorPositions.Add(g.transform.position);
tempList.Add(g);
break;
}
}
}
foreach (GameObject g in tempList)
{
g.SetActive(true);
g.transform.DOScaleY(5, 0.25f).Play();
yield return new WaitForSeconds(0.05f);
}
それがないすべては、道路の一部(tempListリストの最後にあるべきもの)を作成することです。私が望むのは、スクリプトは、他の何かをする前にリストにすべてのプレハブを追加するので、私はその間にいくつか追加することができます。関数をvoidに変更しようとしましたが、このコードの一部をienumeratorとして呼び出し、ループの種類を変更しましたが、何も動作していないように見えます。私はDebug.Logで1つ以上のプレハブをまだ見つけているかどうかを確認しましたが、それは有効ですが、そのうちの1つしかアクティブ化していません。それは明らかに何か私を賭け、しかし、私はちょうどそれを見ることができない:/
、それがどのように見えるか:
を、それが見てどうあるべきか:
をするのを忘れました言及 - IEnumeratorのすべての内部
ないように注意してください、多分あなたは/ http://gamedev.stackexchange.com/でこれを尋ねるべきだろうか? –
最初のパスはネストされ、2番目のパスはネストされません。試してみてください: –
@Kuniqは私の答えを確認します –