array of material unity code example
Example: how to declare a material array unity
using UnityEngine; using System.Collections; public class arrayDemo : MonoBehaviour { System.Random random = new System.Random(); // Set the materials in the inspector public Material[] myMaterials = new Material[5]; // Use this for initialization void Start () { // Assigns a random material at start gameObject.renderer.material = myMaterials[random.Next(0,myMaterials.Length)]; } }