I’m trying to make the color of the sprite change every time its clicked but its not working. I can’t find any examples significant input so far.
using UnityEngine;
using System.Collections;
public class change : MonoBehaviour
{
Color[] colorlist = {Color.yellow, Color.green, Color.blue, Color.red};
private GameObject thingy;
private SpriteRenderer spirit;
void Start()
{
spirit = thingy.GetComponent<SpriteRenderer>();
thingy = GameObject.Find ("Color");
colorChange();
}
// Update is called once per frame
void Update()
{
}
void OnMouseDown()
{
colorChange();
}
void colorChange()
{
spirit.color = colorlist[Random.Range(0, colorlist.Length)];
}
}