Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created August 8, 2017 23:32
Show Gist options
  • Save unity3dcollege/d946c10d88e79d56221cfd5a7c834720 to your computer and use it in GitHub Desktop.
Save unity3dcollege/d946c10d88e79d56221cfd5a7c834720 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.UI;
public class ChooseRandomColor : MonoBehaviour
{
public void ChangeImageColor()
{
GetComponent<Image>().color = RandomColor();
}
private Color RandomColor()
{
return new Color(
UnityEngine.Random.Range(0f, 1f),
UnityEngine.Random.Range(0f, 1f),
UnityEngine.Random.Range(0f, 1f)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment