AutoPrefs.

AutoPrefs.AutoPref<T> Class

Summary

An object which encapsulates a pref value stored with a specific key.
graph BT Type-->Base0["Object"] Type-.->Interface0["AutoPrefs.IAutoPref"] click Interface0 "/inspector-gadgets/api/InspectorGadgets/IAutoPref" Type["AutoPrefs.AutoPref<T>"] class Type type-node Derived0["AutoPrefs.Float"]-->Type click Derived0 "/inspector-gadgets/api/InspectorGadgets/Float" Derived1["AutoPrefs.String"]-->Type click Derived1 "/inspector-gadgets/api/InspectorGadgets/String" Derived2["AutoPrefs.Bool"]-->Type click Derived2 "/inspector-gadgets/api/InspectorGadgets/Bool" Derived3["AutoPrefs.Vector2"]-->Type click Derived3 "/inspector-gadgets/api/InspectorGadgets/Vector2" Derived4["AutoPrefs.Quaternion"]-->Type click Derived4 "/inspector-gadgets/api/InspectorGadgets/Quaternion" Derived5["AutoPrefs.Vector3"]-->Type click Derived5 "/inspector-gadgets/api/InspectorGadgets/Vector3" Derived6["AutoPrefs.Int"]-->Type click Derived6 "/inspector-gadgets/api/InspectorGadgets/Int" Derived7["AutoPrefs.Vector4"]-->Type click Derived7 "/inspector-gadgets/api/InspectorGadgets/Vector4"

Syntax

public abstract class AutoPrefs.AutoPref<T> : AutoPrefs.IAutoPref

Type Parameters

Name Description
T

Constructors

Name Summary
AutoPref(string, T, Action<T>) Constructs an InspectorGadgets.AutoPrefs.AutoPref`1 with the specified `key` and `defaultValue`.

Fields

Name Constant Value Summary
DefaultValue
The default value to use if this pref has no existing value.
Key
The key used to identify this pref.
OnValueChanged
Called when the InspectorGadgets.AutoPrefs.AutoPref`1.Value is changed.

Properties

Name Value Summary
DefaultStyle GUIStyle
[Editor-Only] Draws the default GUI style used by this pref if none is specified when calling InspectorGadgets.AutoPrefs.AutoPref`1.OnGUI(Rect,GUIContent,GUIStyle).
Value T
The current value of this pref.

Methods

Name Value Summary
DeletePref() void
Deletes the value of this pref from the preferences and reverts to the default value.
DoGUIField(Rect, GUIContent, GUIStyle) T
[Editor-Only] Draws a GUI field for this pref and returns the value it is set to.
GetControlRect(GUILayoutOption[]) Rect
Uses UnityEditor.EditorGUILayout.GetControlRect(bool, float, GUIStyle, GUILayoutOption[]) to allocate a GUILayout Rect for a control.
GetControlRect(GUIStyle, GUILayoutOption[]) Rect
Uses UnityEditor.EditorGUILayout.GetControlRect(bool, float, GUIStyle, GUILayoutOption[]) to allocate a GUILayout Rect for a control.
static
GetHashCode() int
Returns a hash code for the current pref value.
IsSaved() bool
Returns true if the preferences currently contains a saved value for this pref.
Load() T
Loads the value of this pref from the system.
OnGUI(GUIContent, AutoPrefs.AutoPref<T>.GUIFieldMethod, GUILayoutOption[]) bool
[Editor-Only] Draws GUI controls for this pref and returns true if the value was changed.
OnGUI(GUIContent, GUILayoutOption[]) bool
[Editor-Only] Draws GUI controls for this pref and returns true if the value was changed.
OnGUI(GUIContent, GUIStyle, AutoPrefs.AutoPref<T>.GUIFieldMethod, GUILayoutOption[]) bool
[Editor-Only] Draws GUI controls for this pref and returns true if the value was changed.
OnGUI(GUIContent, GUIStyle, GUILayoutOption[]) bool
[Editor-Only] Draws GUI controls for this pref and returns true if the value was changed.
OnGUI(Rect, GUIContent, GUIStyle) bool
[Editor-Only] Draws GUI controls for this pref and returns true if the value was changed.
OnGUI(Rect, GUIContent, GUIStyle, AutoPrefs.AutoPref<T>.GUIFieldMethod) bool
[Editor-Only] Draws GUI controls for this pref and returns true if the value was changed.
OnGUI(string, GUILayoutOption[]) bool
[Editor-Only] Draws GUI controls for this pref and returns true if the value was changed.
OnGUI(string, GUIStyle, GUILayoutOption[]) bool
[Editor-Only] Draws GUI controls for this pref and returns true if the value was changed.
Reload() void
Reloads the value of this pref from the system.
RevertToDefaultValue() void
Sets the InspectorGadgets.AutoPrefs.AutoPref`1.Value = InspectorGadgets.AutoPrefs.AutoPref`1.DefaultValue.
Save() void
Saves the value of this pref to the system.
ToString() string
Returns Value?.ToString().

Operators

Name Value Summary
implicit operator T(AutoPrefs.AutoPref<T>) T
operator !=(AutoPrefs.AutoPref<T>, T) bool
operator ==(AutoPrefs.AutoPref<T>, T) bool