WHat im trying to do is make it so that when i click on the button i want it to turn red, heres my code im not sure what wrong with it. Can anyone help me out with this. Thanks in advance.
using UnityEngine;
using System.Collections;
public class GameTabs5 : MonoBehaviour {
void OnGUI(){
if (GUI.Button(new Rect(140,35,70,35), "Traps")){
GUI.color = Color.red;
}
}
}
OnGUI is a bit hard to get the hang of to start with
It is called every frame, so you just set a bool true when it has been clicked and use that on the subsequent frames:
using UnityEngine;
using System.Collections;
public class GameTabs5 : MonoBehaviour {
bool buttonClicked = false;
void OnGUI(){
if(buttonClicked)
GUI.color = Color.red;
if (GUI.Button(new Rect(140,35,70,35), "Traps")){
buttonClicked = true;
}
}
}