/// <summary> /// Spawns a prefab at one of the set locations without modifying the spawnedCount value. /// </summary> private Transform Spawn() { int prefabIndex = GetNextSpawnIndex(); if (prefabIndex == -1) { Debug.LogWarning("[Pooly][PoolySpawner] The " + name + " PoolySpawner is trying to spawn a null prefab. Check your referenced prefab slots, one or more may be empty."); return(null); } GenerateNextSpawnParametersSet(); if (!matchTransformScale) { return(Pooly.Spawn(spawnPrefabs[prefabIndex].prefab, nextSpawnParams.spawnPosition, nextSpawnParams.spawnRotation, nextSpawnParams.parent)); } else { return(Pooly.Spawn(spawnPrefabs[prefabIndex].prefab, nextSpawnParams.spawnPosition, nextSpawnParams.spawnRotation, nextSpawnParams.spawnScale, nextSpawnParams.parent)); } }
/// <summary> /// Spawns the given prefab at one of the set locations without modifying the spawnedCount value. /// <para>Note: The prefab has to be registered to this spawner in order to work (and in the Pooly pool as well)</para> /// </summary> /// <param name="prefab">Target prefab.</param> private Transform Spawn(Transform prefab) { if (prefab == null) { return(null); } if (!IsRegisteredPrefab(prefab)) { return(null); } GenerateNextSpawnParametersSet(); if (!matchTransformScale) { return(Pooly.Spawn(prefab, nextSpawnParams.spawnPosition, nextSpawnParams.spawnRotation, nextSpawnParams.parent)); } else { return(Pooly.Spawn(prefab, nextSpawnParams.spawnPosition, nextSpawnParams.spawnRotation, nextSpawnParams.spawnScale, nextSpawnParams.parent)); } }