- Home /
 
GUI texture updating in preview but not in game
I'm trying to make a main menu screen, but when I hover over the "Play Game" or "Quit" button, the color changes in preview but not in game. Here's the code I'm using. I don't use a function update because the OnMouseEnter and OnMouseExit beacuse they should be self updating. Please help, thanks!
 var isQuitButton = false ; 
 
  function OnMouseOver()
 {
     renderer.material.color = Color.green;
 }
  
  
  function OnMouseExit()
  {
         renderer.material.color = Color.black;
 }
 function OnMouseUp()
 {
     //are we dealing with a quit button
     if( isQuitButton)
     {
         //quit the game
         Application.Quit();
     }
     
     else 
     {
         //load level
         Application.LoadLevel(1);
     }
 }
 
              
               Comment
              
 
               
              Answer by 1elfdragon1 · Feb 11, 2014 at 04:21 PM
try to use the text mesh component to change the color. so it looks something like:
 #pragma strict
 
 var isQuitButton : boolean = false;
 var textMesh : TextMesh = null;
 
 function Start() {
     textMesh = gameObject.GetComponent(TextMesh);
 }
 
 function OnMouseOver() {
     textMesh.color = Color.green;
     if (Input.GetButton ("Fire 1")) {
         textMesh.color = Color.white;
     }
     if (Input.GetButtonUp("Fire 1")) {
         if (isQuitButton) {
             Application.Quit();
         }
         else {
             Application.LoadLevel(1);
         }
     }
 }
 
 function OnMouseExit() {
     textMesh.color = Color.black;
 }
 
               i hope that this solved your problem
Your answer