Hello,
I have code that changes a UI text and it works perfectly.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Finish : MonoBehaviour {
string myText;
public int score = 0;
public Text Status;
GameObject myTextgameObject; // gameObject in Hierarchy
Text ourComponent; // Our refference to text component
// Use this for initialization
void Start () {
if (PlayerPrefs.HasKey("Score") == true)
{
score = PlayerPrefs.GetInt("Score");
}
// Find gameObject with name "MyText"
myTextgameObject = GameObject.Find("MyText");
// Get component Text from that gameObject
ourComponent = myTextgameObject.GetComponent<Text>();
if(score == 7 || score == 8){
Status.text = "Excellent!";
Status.color = Color.green;
}
if(score == 5 || score == 6){
Status.text = "Pretty Good!";
Status.color = Color.green;
}
if(score == 3 || score == 4){
Status.text = "Okay!";
Status.color = Color.yellow;
}
if(score == 0 || score == 1 || score == 2){
Status.text = "Better luck next time!";
Status.color = Color.red;
}
}
// Update is called once per frame
void Update () {
ourComponent.text = score.ToString();
}
}
The problem is that I’m only restricted to using the words red, yellow, blue, green, black, cyan etc. But for example, I want range but that word doesn’t exist in the Unity editor. Well… I would like to have an advanced colour. Can I somehow create a new colour with a Hex code or a RGBA code or anything else like that?.