- Home /
Question by
teopotter88 · Oct 13, 2016 at 10:55 AM ·
buttonbool
Bool to button?
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?
Comment
Answer by Zodiarc · Oct 13, 2016 at 11:28 AM
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