Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class randomgen : MonoBehaviour {
- public GameObject[] prefs = new GameObject[3];
- public int gridX = 5;
- private float y = 0;
- public float spacing = 2f;
- // Use this for initialization
- void Start () {
- for (int x = 0; x < gridX; x++) {
- Vector3 pos = new Vector3(x * spacing + 0, 3, y);
- int rndId = Random.Range(0, prefs.Length);
- Instantiate(prefs[rndId], pos, Quaternion.identity);
- GameObject temp = prefs [rndId];
- prefs [rndId] = prefs [prefs.Length - 1];
- prefs [prefs.Length - 1] = temp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement