public void GeneratePlatform() { if (platformAmount < templatePlatform.Length) { PlatformControl perfabs = Instantiate(templatePlatform[platformAmount]); perfabs.SetPos(platformLastPos); perfabs.transform.SetParent(platformPlace); activePlatform.Add(perfabs); platformAmount++; } else { int ranNumber2 = Random.Range(0, unActivePlatform.Count); unActivePlatform[ranNumber2].SetPos(platformLastPos); platformLastPos = unActivePlatform[ranNumber2].GetLastPos(); activePlatform.Add(unActivePlatform[ranNumber2]); unActivePlatform.RemoveAt(ranNumber2); } }