public button button1 = (GUI.Button (new Rect (800, 100, 100, 100), “YES”));
public button button2 = (GUI.Button (new Rect (600, 100, 100, 100), “NO”));
It gives an error to this as “Cannot implicitly convert bool to button.” How can I fix this?
public button button1 = (GUI.Button (new Rect (800, 100, 100, 100), “YES”));
public button button2 = (GUI.Button (new Rect (600, 100, 100, 100), “NO”));
It gives an error to this as “Cannot implicitly convert bool to button.” How can I fix this?
The legacy GUI button returns a bool if it had been clicked or not. You can’ t store it in a variable.
if(GUI.Button(...)) {
// The first button has been clicked
} else if (GUI.Button(...)) {
// The second button as been clicked
}
will work, but i recommend to switching to the UI system that was introduced in Unity 4.6