I’ve tried to alter a material script to get game objects instead.
Not quite working as planned.
using UnityEngine;
using System.Collections;
public class RandomMaterial : MonoBehaviour {
public GameObject[] gameObject;
int current;
// Use this for initialization
void Start () {
}
// Update is called once per frame
public void Switch () {
current++;
if (current >= gameObject.Length)
current = 0;
GetComponent<GameObject> = gameObject[current];
}
}
Original Code
using UnityEngine;
using System.Collections;
public class RandomMaterial : MonoBehaviour {
public Material[] materials;
int current;
// Use this for initialization
void Start () {
}
// Update is called once per frame
public void Switch () {
current++;
if (current >= materials.Length)
current = 0;
GetComponent<Renderer>().material = materials[current];
}
}