Skip to content

Instantly share code, notes, and snippets.

@jbasinger
Created January 13, 2017 01:46
Show Gist options
  • Save jbasinger/72354ef608537c76eaebd6a684dbd3ad to your computer and use it in GitHub Desktop.
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
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