|
Hi folks, I'd like to make a button which looks like a toggle, that can perform a series of commands when clicked, and updates the checkbox to appear checked or unchecked. In other words, I'd like to be able to click on something that looks like a toggle button and have it call a function or two and update the toggle button's status. But I can't figure out how to make a button which looks like a toggle also update the toggle status and still perform commands when clicked. Here are some things I've tried: // this always looked unchecked and doesn't do anything when clicked
toggle = GUILayout.Button("Invert Button", "toggle");
// this does something when clicked but still always looks unchecked
if (GUILayout.Button("Invert Vertical Camera Movement", "toggle")) {
InvertAxis("Vertical");
toggle = !toggle;
}
// this obviously doesn't work
toggle = if (GUILayout.Button("Invert Vertical Camera Movement", "toggle")) {
InvertAxis("Vertical");
toggle = !toggle;
}How can this be done? If there's no way to do it then what's the point in being able to make a button look like a toggle box if you can't get it to show the status of the toggle?
(comments are locked)
|
