UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"changing colors mesh and sprite"
public class ChangingColors : MonoBehaviour { public static ColorBank instance; public Color[] colorBank; public bool sprite; public bool mesh; // Start is called before the first frame update void Start() { int num = Random.Range(0, colorBank.Length); if (mesh) { MeshRenderer m = GetComponent<MeshRenderer>(); m.material.color = colorBank[num]; } if (sprite) { SpriteRenderer s = GetComponent<SpriteRenderer>(); s.color = colorBank[num]; } }