I presumed this was going to be an easy task, but it has proved very annoying and I am at my wits end here. I have a GUI.toggle button which is declared in the onGUI() method all I want to do is return the bool value of the GUI.toggle to indicate if it is clicked or not. The problem I am getting is that the value of the GUI.toogle button never changes even if it is clicked ? Below is the code I have thanks to anyone who can help
public class checkValue : MonoBehaviour {
public Texture2D SubmitButton;
public bool val;
public bool values = true;
void OnGUI()
{
val = GUI.Toggle(new Rect(120, 260, 130, 20), val,"helo");
if(val != values){
val = false;
Debug.Log(val);
}
else if(val == values){
val = true;
Debug.Log(val);
}
}
}