Created
December 24, 2015 11:31
-
-
Save robertcedwards/40014e97a5f8827f7f65 to your computer and use it in GitHub Desktop.
Spawn random prefab in Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Transform[] prefabs; | |
void SpawnANewOne() { | |
int index = Random.Range(0, prefabs.Count); | |
Transform randomPrefab = prefabs[index]; | |
Instantiate(randomPrefab); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment