Base class for creating custom overlay toggle buttons with persistent state. More...
Public Member Functions | |
| void | OnValueChanged (bool newValue) |
| Called when the toggle value changes newValue: The new toggle state (true/false) | |
| virtual bool | ShouldShow (GameObject selectedObject) |
| Optional: Determines if the toggle should be shown based on current selection. | |
| virtual bool | ShouldEnable () |
| Optional: Determines if the toggle should be enabled. | |
| virtual VisualElement | CreateButton () |
| Creates the visual element for this toggle. | |
| void | RefreshValue () |
| Programmatically refresh the toggle state from preferences. | |
Protected Member Functions | |
| bool | GetValue () |
| Gets the current toggle value from EditorPrefs (or default if no preference set) | |
| void | SetValue (bool value) |
| Sets the toggle value and saves to EditorPrefs. | |
| Texture | LoadIcon (string path) |
| Helper method to load an icon from the project. | |
| VisualElement | CreateIconElement (Texture icon, int size=16) |
| Helper method to create an icon element. | |
Properties | |
| virtual string | ButtonText [get] |
| Text displayed on the button (can be null if using icon only) | |
| virtual string | Tooltip [get] |
| Tooltip text shown on hover. | |
| virtual Texture | Icon [get] |
| Icon texture for the button (can be null if using text only) | |
| virtual string | CssClass [get] |
| Additional CSS class names to apply to the toggle (for custom styling) | |
| virtual bool | IconOnly [get] |
| Whether this button uses icon only (no text) | |
| virtual string | PreferenceKey [get] |
| EditorPrefs key for storing toggle state (override this for persistent state) If null, state is not persisted across sessions. | |
| virtual bool | DefaultValue [get] |
| Default value when no preference is stored. | |
Detailed Description
Base class for creating custom overlay toggle buttons with persistent state.
Inherit from this class to create toggle buttons that maintain their state across sessions.
Example usage:
Member Function Documentation
◆ CreateButton()
|
virtual |
Creates the visual element for this toggle.
Implements realvirtual.IOverlayButton.
◆ CreateIconElement()
|
protected |
Helper method to create an icon element.
◆ GetValue()
|
protected |
Gets the current toggle value from EditorPrefs (or default if no preference set)
◆ LoadIcon()
|
protected |
Helper method to load an icon from the project.
◆ OnValueChanged()
|
abstract |
Called when the toggle value changes newValue: The new toggle state (true/false)
◆ RefreshValue()
| void realvirtual.OverlayToggleBase.RefreshValue | ( | ) |
Programmatically refresh the toggle state from preferences.
◆ SetValue()
|
protected |
Sets the toggle value and saves to EditorPrefs.
◆ ShouldEnable()
|
virtual |
Optional: Determines if the toggle should be enabled.
Implements realvirtual.IOverlayButton.
◆ ShouldShow()
|
virtual |
Optional: Determines if the toggle should be shown based on current selection.
Implements realvirtual.IOverlayButton.
Property Documentation
◆ ButtonText
|
get |
Text displayed on the button (can be null if using icon only)
◆ CssClass
|
get |
Additional CSS class names to apply to the toggle (for custom styling)
◆ DefaultValue
|
getprotected |
Default value when no preference is stored.
◆ Icon
|
get |
Icon texture for the button (can be null if using text only)
◆ IconOnly
|
get |
Whether this button uses icon only (no text)
◆ PreferenceKey
|
getprotected |
EditorPrefs key for storing toggle state (override this for persistent state) If null, state is not persisted across sessions.
◆ Tooltip
|
get |
Tooltip text shown on hover.