Hello,
is this right, when I have only normal Buttons the GUI.changed function ignore the clicks?
public void OnGUI(){
selectedToolbar = GUI.Toolbar (new Rect (50, 10, Screen.width - 100, 30), selectedToolbar, toolbarStrings);
if (GUI.Button (new Rect (Screen.width/2-200, Screen.height/2+118, 240, 70), “Button1”)) {
}
if (GUI.Button (new Rect (Screen.width/2+100, Screen.height/2+118, 240, 70), “Button2”)) {
}
if (GUI.changed){
print(“clicked”);
}
}
GUI.changed only applies to controls that store state information (text controls, sliders, etc). A button click isn’t counted because there is no state change that persists beyond the user’s action.
For future reference, I have found that it is possible to manually assign true to GUI.changed, which makes it a bit easier to streamline GUI code if you need to track button presses along with control state changes and check GUI.changed at the end of the OnGUI loop.