IEnumerator SpawnSequence(Vector3 position, float spawnDelay) { for (int i = 0; i < rewardAmount.Value; i++) { Instantiate(rewards.GetRandom(), position, Quaternion.identity); yield return(new WaitForSeconds(spawnDelay)); } }
void Instantiate(Vector3 pos) { #if UNITY_EDITOR var prefab = toSpawn.GetRandom(); var instance = UnityEditor.PrefabUtility.InstantiatePrefab(prefab) as GameObject; float newScale = Random.Range(spawnedScale.x, spawnedScale.y); instance.transform.localScale *= newScale; instance.transform.position = pos; instance.transform.parent = parent ? parent : transform; instances.Add(instance); #endif }