Created
January 13, 2017 01:46
-
-
Save jbasinger/72354ef608537c76eaebd6a684dbd3ad to your computer and use it in GitHub Desktop.
A simple script for Unity where you can put in a list of prefabs to pull from randomly
This file contains hidden or 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class RandomModelGenerator : MonoBehaviour { | |
public GameObject[] prefabs; | |
public int seed; | |
// Use this for initialization | |
void Start () { | |
//Initialize with a seed here if you want | |
//Random.InitState (seed); | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
public GameObject RandomModel() { | |
if (prefabs.Length == 0){ | |
return null; | |
} | |
return prefabs[Random.Range (0, prefabs.Length)]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment