- Home /
Change Text Color
Hi, I have this code on my word:
function Update () {
renderer.material.color = Color.red;
}
But this is on a Start Game button so when I put this code on it also:
var isQuit=false;
function OnMouseEnter(){
//change text color
renderer.material.color=Color.grey;
}
function OnMouseExit(){
//change text color
renderer.material.color=Color.red;
}
function OnMouseUp(){
//is this quit
if (isQuit==true) {
//quit the game
Application.Quit();
}
else {
//load level
Application.LoadLevel(0);
}
}
function Update(){
//quit game if escape key is pressed
if (Input.GetKey(KeyCode.Escape)) { Application.Quit();
}
}
And this part of the code does not work:
function OnMouseEnter(){
//change text color
renderer.material.color=Color.grey;
}
function OnMouseExit(){
//change text color
renderer.material.color=Color.red;
}
I think this is because the first code is blocking out the grey. How do I fix this?
Comment
Answer by Joyrider · Aug 14, 2013 at 12:33 AM
I don't really understand your question... or what you want to do exactly
But, what I can tell you is that in your code the Update function (which is called every frame) sets your material color to red, so you will never have anything other than red...
yes so how do I make it update so the second code can change the color to grey when the mouse enters the text?
Your answer
![](https://koobas.hobune.stream/wayback/20220613112144im_/https://answers.unity.com/themes/thub/images/avi.jpg)