When I instantiate a GameObject and want to add it to a List in a List and later check the List in the List if there are any GameObjects it says 0.
Instantiation
public async Task Prepare()
{
int currentSeed;
for (int i = 0; i < manager.pit.Length; i++)
{
currentSeed = 0;
for (int j = 0; j < manager.pit[i]; j++)
{
GameObject addme;
await Task.Delay(10);
Vector3 point = spawnPoint[i].transform.position;
point.y = point.y + 0.04f;
Quaternion rotation = spawnPoint[j].transform.rotation;
addme = (GameObject)Instantiate(seed, point, rotation);
seeds[i].Add(addme);
currentSeed++;
}
}
}
Debug
public IEnumerator MoveSeed(int pit, Vector3[] targetPos)
{
for (int i = 0; i < seeds[pit].Count; i++)
{
GameObject send = seeds[pit][i];
yield return new WaitForSeconds(2);
Debug.Log($"{seeds[pit].Count}"); //Here it says 0
SeedMover(send, targetPos[i]);
}
}
I thought that maybe it’s because of the public async Task.