Skip to content

Instantly share code, notes, and snippets.

@robertcedwards
Created December 24, 2015 11:31
Show Gist options
  • Save robertcedwards/40014e97a5f8827f7f65 to your computer and use it in GitHub Desktop.
Save robertcedwards/40014e97a5f8827f7f65 to your computer and use it in GitHub Desktop.
Spawn random prefab in Unity
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