Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static GUIStyle _toggleOff;
- private static GUIStyle _toggleOn;
- public static bool ToggleButton(string name, bool state, GUILayoutOption option = null) {
- if (_toggleOff == null) {
- _toggleOff = new GUIStyle(GUI.skin.button);
- _toggleOn = new GUIStyle(GUI.skin.button);
- _toggleOn.normal = _toggleOn.onActive;
- }
- if (option == null) {
- if (GUILayout.Button(name, state ? _toggleOn : _toggleOff))
- return !state;
- }
- else {
- if (GUILayout.Button(name, state ? _toggleOn : _toggleOff, option))
- return !state;
- }
- return state;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement