### Example Button for Dockable Window Source: https://odininspector.com/attributes/responsive-button-group-attribute A sample method decorated with Button and GUIColor attributes, intended to open a dockable window. This snippet is part of a larger example demonstrating Odin Inspector's capabilities. ```csharp [Button(ButtonSizes.Large), GUIColor(0, 1, 0)] private void OpenDockableWindowExample() { var window = UnityEditor.EditorWindow.GetWindow(); window.WindowPadding = new Vector4(); } ``` -------------------------------- ### Initialization of Preview Fields Source: https://odininspector.com/attributes/preview-field-attribute This method initializes various fields, including those using the PreviewField attribute, with example data. ```csharp [OnInspectorInit] private void CreateData() { RegularPreviewField = ExampleHelper.GetTexture(); D = ExampleHelper.GetTexture(); E = ExampleHelper.GetTexture(); I = ExampleHelper.GetMesh(); preview = ExampleHelper.GetTexture(); } ``` -------------------------------- ### Custom List Element GUI Implementation Source: https://odininspector.com/attributes/list-drawer-settings-attribute Example implementations for drawing custom GUI elements at the beginning and end of list elements. ```csharp private void BeginDrawListElement(int index) { SirenixEditorGUI.BeginBox(this.InjectListElementGUI[index].SomeString); } private void EndDrawListElement(int index) { SirenixEditorGUI.EndBox(); } ``` -------------------------------- ### OnInspectorGUI on Methods Source: https://odininspector.com/attributes/on-inspector-guiattribute This example shows how OnInspectorGUI can be directly applied to a method to display an EditorGUI.HelpBox. This illustrates the attribute's versatility in targeting both properties and methods. ```csharp [OnInspectorGUI] private void OnInspectorGUI() { UnityEditor.EditorGUILayout.HelpBox("OnInspectorGUI can also be used on both methods and properties", UnityEditor.MessageType.Info); } ``` -------------------------------- ### MinMaxSlider with Dynamic Minimum and Static Maximum Source: https://odininspector.com/attributes/min-max-slider-attribute This example shows how to set a dynamic minimum value by referencing a member, while keeping the maximum value static. ```csharp [MinMaxSlider("Min", 10f, true)] public Vector2 DynamicMin = new Vector2(2, 7); ``` -------------------------------- ### Simple Toggle Group Example Source: https://odininspector.com/attributes/toggle-group-attribute Demonstrates how to use ToggleGroup to create a simple toggleable group for a boolean field and other fields. ```csharp // Simple Toggle Group [ToggleGroup("MyToggle")] public bool MyToggle; [ToggleGroup("MyToggle")] public float A; [ToggleGroup("MyToggle")] [HideLabel, Multiline] public string B; ``` -------------------------------- ### ValidateInput Attribute Examples Source: https://odininspector.com/attributes/validate-input-attribute Demonstrates various ways to use the ValidateInput attribute for input validation in Odin Inspector. Includes examples for default messages, dynamic messages, and dynamic message types. ```csharp [HideLabel] [Title("Default message", "You can just provide a default message that is always used")] [ValidateInput("MustBeNull", "This field should be null.")] public MyScriptyScriptableObject DefaultMessage; [Space(12), HideLabel] [Title("Dynamic message", "Or the validation method can dynamically provide a custom message")] [ValidateInput("HasMeshRendererDynamicMessage", "Prefab must have a MeshRenderer component")] public GameObject DynamicMessage; [Space(12), HideLabel] [Title("Dynamic message type", "The validation method can also control the type of the message")] [ValidateInput("HasMeshRendererDynamicMessageAndType", "Prefab must have a MeshRenderer component")] public GameObject DynamicMessageAndType; [Space(8), HideLabel] [InfoBox("Change GameObject value to update message type", InfoMessageType.None)] public InfoMessageType MessageType; [Space(12), HideLabel] [Title("Dynamic default message", "Use $ to indicate a member string as default message")] [ValidateInput("AlwaysFalse", "$Message", InfoMessageType.Warning)] public string Message = "Dynamic ValidateInput message"; private bool AlwaysFalse(string value) { return false; } private bool MustBeNull(MyScriptyScriptableObject scripty) { return scripty == null; } private bool HasMeshRendererDefaultMessage(GameObject gameObject) { if (gameObject == null) return true; return gameObject.GetComponentInChildren() != null; } private bool HasMeshRendererDynamicMessage(GameObject gameObject, ref string errorMessage) { if (gameObject == null) return true; if (gameObject.GetComponentInChildren() == null) { // If errorMessage is left as null, the default error message from the attribute will be used errorMessage = "\"" + gameObject.name + "\" must have a MeshRenderer component"; return false; } return true; } private bool HasMeshRendererDynamicMessageAndType(GameObject gameObject, ref string errorMessage, ref InfoMessageType? messageType) { if (gameObject == null) return true; if (gameObject.GetComponentInChildren() == null) { // If errorMessage is left as null, the default error message from the attribute will be used errorMessage = "\"" + gameObject.name + "\" should have a MeshRenderer component"; // If messageType is left as null, the default message type from the attribute will be used messageType = this.MessageType; return false; } return true; } ``` -------------------------------- ### PolymorphicDrawerSettings Examples Source: https://odininspector.com/attributes/polymorphic-drawer-settings-attribute Demonstrates various configurations of the PolymorphicDrawerSettings attribute for controlling the display and behavior of polymorphic fields. ```csharp [ShowInInspector] public IDemo Default; [Title("Show Base Type"), ShowInInspector, LabelText("On")] [PolymorphicDrawerSettings(ShowBaseType = true)] public IDemo ShowBaseType_On; [ShowInInspector, LabelText("Off")] [PolymorphicDrawerSettings(ShowBaseType = false)] public IDemo ShowBaseType_Off; [Title("Read Only If Not Null Reference"), ShowInInspector, LabelText("On")] [PolymorphicDrawerSettings(ReadOnlyIfNotNullReference = true)] public IDemo ReadOnlyIfNotNullReference_On; [ShowInInspector, LabelText("Off")] [PolymorphicDrawerSettings(ReadOnlyIfNotNullReference = false)] public IDemo ReadOnlyIfNotNullReference_Off; [Title("Non Default Constructor Preference"), ShowInInspector, LabelText("Exclude")] [PolymorphicDrawerSettings(NonDefaultConstructorPreference = NonDefaultConstructorPreference.Exclude)] public IVector2 NonDefaultConstructorPreference_Ignore; [ShowInInspector, LabelText("Construct Ideal")] [PolymorphicDrawerSettings(NonDefaultConstructorPreference = NonDefaultConstructorPreference.ConstructIdeal)] public IVector2 NonDefaultConstructorPreference_ConstructIdeal; [ShowInInspector, LabelText("Prefer Uninitialized")] [PolymorphicDrawerSettings(NonDefaultConstructorPreference = NonDefaultConstructorPreference.PreferUninitialized)] public IVector2 NonDefaultConstructorPreference_PreferUninit; [ShowInInspector, LabelText("Log Warning")] [PolymorphicDrawerSettings(NonDefaultConstructorPreference = NonDefaultConstructorPreference.LogWarning)] public IVector2 NonDefaultConstructorPreference_LogWarning; [Title("Create Custom Instance"), ShowInInspector] [PolymorphicDrawerSettings(CreateInstanceFunction = nameof(CreateInstance))] public IVector2 CreateCustomInstance; ``` -------------------------------- ### Button Group Attribute Examples Source: https://odininspector.com/attributes/button-attribute Demonstrates how to group buttons together using the ButtonGroup attribute, including custom group names and styling within groups. ```csharp public IconButtonGroupExamples iconButtonGroupExamples; [ButtonGroup] private void A() { } [ButtonGroup] private void B() { } [ButtonGroup] private void C() { } [ButtonGroup] private void D() { } [Button(ButtonSizes.Large)] [ButtonGroup("My Button Group")] private void E() { } [GUIColor(0, 1, 0)] [ButtonGroup("My Button Group")] private void F() { } [Serializable, HideLabel] public struct IconButtonGroupExamples { [ButtonGroup(ButtonHeight = 25), Button(SdfIconType.ArrowsMove, "")] void ArrowsMove() { } [ButtonGroup, Button(SdfIconType.Crop, "")] void Crop() { } [ButtonGroup, Button(SdfIconType.TextLeft, "")] void TextLeft() { } [ButtonGroup, Button(SdfIconType.TextRight, "")] void TextRight() { } [ButtonGroup, Button(SdfIconType.TextParagraph, "")] void TextParagraph() { } [ButtonGroup, Button(SdfIconType.Textarea, "")] void Textarea() { } } ``` -------------------------------- ### Helper Interfaces and Classes Source: https://odininspector.com/attributes/polymorphic-drawer-settings-attribute Provides definitions for interfaces and classes used in the polymorphic drawer settings examples, including IVector2, SomeNonDefaultCtorClass, and various IDemo implementations. ```csharp public interface IVector2 { T X { get; set; } T Y { get; set; } } [Serializable] public class SomeNonDefaultCtorClass : IVector2 { [OdinSerialize] public int X { get; set; } [OdinSerialize] public int Y { get; set; } public SomeNonDefaultCtorClass(int x) { this.X = x; this.Y = (x + 1) * 4; } } public interface IDemo { T Value { get; set; } } [Serializable] public class DemoSOInt32 : SerializedScriptableObject, IDemo { [OdinSerialize] public int Value { get; set; } } [Serializable] public class DemoSOInt32Target : SerializedScriptableObject, IDemo { [OdinSerialize] public int Value { get; set; } public int target; } [Serializable] public class DemoSOFloat32 : SerializedScriptableObject, IDemo { [OdinSerialize] public float Value { get; set; } } [Serializable] public class Demo : IDemo { [OdinSerialize] public T Value { get; set; } } [Serializable] public class DemoInt32Interface : IDemo { [OdinSerialize] public int Value { get; set; } } public class DemoInt32 : Demo { } public struct DemoStructInt32 : IDemo { [OdinSerialize] public int Value { get; set; } } ``` -------------------------------- ### Custom Add Function Implementation Source: https://odininspector.com/attributes/list-drawer-settings-attribute Example implementation of a custom add function for a list, returning the current count of elements. ```csharp private int CustomAddFunction() { return this.CustomAddBehaviour.Count; } ``` -------------------------------- ### Button Attribute Examples Source: https://odininspector.com/attributes/button-attribute Demonstrates various ways to use the Button attribute, including dynamic names, expression labels, size, color, and conditional visibility. ```csharp public string ButtonName = "Dynamic button name"; public bool Toggle; [Button("$ButtonName")] private void DefaultSizedButton() { this.Toggle = !this.Toggle; } [Button("@\"Expression label: \" + DateTime.Now.ToString(\"HH:mm:ss\")")] public void ExpressionLabel() { this.Toggle = !this.Toggle; } [Button("Name of button")] private void NamedButton() { this.Toggle = !this.Toggle; } [Button(ButtonSizes.Small)] private void SmallButton() { this.Toggle = !this.Toggle; } [Button(ButtonSizes.Medium)] private void MediumSizedButton() { this.Toggle = !this.Toggle; } [DisableIf("Toggle")] [HorizontalGroup("Split", 0.5f)] [Button(ButtonSizes.Large), GUIColor(0.4f, 0.8f, 1)] private void FanzyButton1() { this.Toggle = !this.Toggle; } [HideIf("Toggle")] [VerticalGroup("Split/right")] [Button(ButtonSizes.Large), GUIColor(0, 1, 0)] private void FanzyButton2() { this.Toggle = !this.Toggle; } [ShowIf("Toggle")] [VerticalGroup("Split/right")] [Button(ButtonSizes.Large), GUIColor(1, 0.2f, 0)] private void FanzyButton3() { this.Toggle = !this.Toggle; } [Button(ButtonSizes.Gigantic)] private void GiganticButton() { this.Toggle = !this.Toggle; } [Button(90)] private void CustomSizedButton() { this.Toggle = !this.Toggle; } [Button(Icon = SdfIconType.Dice1Fill, IconAlignment = IconAlignment.LeftOfText)] private void IconButton01() { this.Toggle = !this.Toggle; } [Button(Icon = SdfIconType.Dice2Fill, IconAlignment = IconAlignment.LeftOfText)] private void IconButton02() { this.Toggle = !this.Toggle; } ``` -------------------------------- ### Basic Property Tooltip Source: https://odininspector.com/attributes/property-tooltip-attribute Apply PropertyTooltip to any property to display a tooltip when hovering in the inspector. This example shows a tooltip for an integer property. ```csharp [PropertyTooltip("This is tooltip on an int property.")] public int MyInt; ``` -------------------------------- ### Wrap Attribute Examples Source: https://odininspector.com/attributes/wrap-attribute Demonstrates the application of the Wrap attribute to various property types, including integers, floats, and Vector3, for creating cyclical value ranges. ```csharp [Wrap(0f, 100f)] public int IntWrapFrom0To100; [Wrap(0f, 100f)] public float FloatWrapFrom0To100; [Wrap(0f, 100f)] public Vector3 Vector3WrapFrom0To100; [Wrap(0f, 360)] public float AngleWrap; [Wrap(0f, Mathf.PI * 2)] public float RadianWrap; ``` -------------------------------- ### Initialize Property with OnInspectorInit Source: https://odininspector.com/attributes/on-inspector-init-attribute This example demonstrates using OnInspectorInit to set a string property to the current time when it's first drawn or reselected in the inspector. The action string specifies the method or expression to execute. ```csharp // OnInspectorInit executes the first time this string is about to be drawn in the inspector. // It will execute again when the example is reselected. [OnInspectorInit("@TimeWhenExampleWasOpened = DateTime.Now.ToString()")] public string TimeWhenExampleWasOpened; ``` -------------------------------- ### Custom Value Drawer Attribute Examples Source: https://odininspector.com/attributes/custom-value-drawer-attribute Demonstrates various ways to use the CustomValueDrawer attribute with static methods, instance methods, and methods that handle appended drawing logic or array elements. ```csharp public float From = 2, To = 7; [CustomValueDrawer("MyCustomDrawerStatic")] public float CustomDrawerStatic; [CustomValueDrawer("MyCustomDrawerInstance")] public float CustomDrawerInstance; [CustomValueDrawer("MyCustomDrawerAppendRange")] public float AppendRange; [CustomValueDrawer("MyCustomDrawerArrayNoLabel")] public float[] CustomDrawerArrayNoLabel = new float[] { 3f, 5f, 6f }; private static float MyCustomDrawerStatic(float value, GUIContent label) { return EditorGUILayout.Slider(label, value, 0f, 10f); } private float MyCustomDrawerInstance(float value, GUIContent label) { return EditorGUILayout.Slider(label, value, this.From, this.To); } private float MyCustomDrawerAppendRange(float value, GUIContent label, Func callNextDrawer) { SirenixEditorGUI.BeginBox(); callNextDrawer(label); var result = EditorGUILayout.Slider(value, this.From, this.To); SirenixEditorGUI.EndBox(); return result; } private float MyCustomDrawerArrayNoLabel(float value) { return EditorGUILayout.Slider(value, this.From, this.To); } ``` -------------------------------- ### Example Usage of HideInInlineEditors Source: https://odininspector.com/attributes/hide-in-inline-editors-attribute Demonstrates how to use the HideInInlineEditors attribute to hide a property within an InlineEditor. This example shows how to initialize and clean up a ScriptableObject used with InlineEditor. ```csharp [InfoBox("Click the pen icon to open a new inspector window for the InlineObject too see the differences these attributes make.")] [InlineEditor(Expanded = true)] public MyInlineScriptableObject InlineObject; [OnInspectorInit] private void CreateData() { InlineObject = ExampleHelper.GetScriptableObject("Inline Object"); } [OnInspectorDispose] private void CleanupData() { if (InlineObject != null) Object.DestroyImmediate(InlineObject); } ``` -------------------------------- ### Toggle Left Attribute Example Source: https://odininspector.com/attributes/toggle-left-attribute Demonstrates using the ToggleLeft attribute to place the boolean toggle before its label. This example also shows how to use EnableIf to conditionally show other fields based on the state of the toggled boolean. ```csharp [InfoBox("Draws the toggle button before the label for a bool property.")] [ToggleLeft] public bool LeftToggled; [EnableIf("LeftToggled")] public int A; [EnableIf("LeftToggled")] public bool B; [EnableIf("LeftToggled")] public bool C; ``` -------------------------------- ### Basic Type Field Source: https://odininspector.com/attributes/type-drawer-settings-attribute A simple example of a public Type field that can be displayed in the inspector. ```csharp [ShowInInspector] public Type Default; ``` -------------------------------- ### Custom ValueDropdown List for Scriptable Objects Source: https://odininspector.com/attributes/value-dropdown-attribute Demonstrates how to create a ValueDropdown list populated with ScriptableObject assets from the project. ```csharp private static IEnumerable GetAllScriptableObjects() { return UnityEditor.AssetDatabase.FindAssets("t:ScriptableObject") .Select(x => UnityEditor.AssetDatabase.GUIDToAssetPath(x)) .Select(x => new ValueDropdownItem(x, UnityEditor.AssetDatabase.LoadAssetAtPath(x))); } ``` -------------------------------- ### Interface Definitions Source: https://odininspector.com/attributes/type-drawer-settings-attribute Defines interfaces used for type filtering examples, including generic and non-generic variants. ```csharp public interface IBaseGeneric { } public interface IBase : IBaseGeneric { } ``` -------------------------------- ### Basic Asset List Usage Source: https://odininspector.com/attributes/asset-list-attribute Demonstrates how to use the AssetList attribute to filter assets by path for a single object and a list. ```csharp [AssetList(Path = "/Plugins/Sirenix/")] public List AssetList; ``` ```csharp [FoldoutGroup("Filtered Odin ScriptableObjects", expanded: false)] [AssetList(Path = "Plugins/Sirenix/")] public ScriptableObject Object; ``` -------------------------------- ### Initialize Dictionaries in OnInspectorInit Source: https://odininspector.com/attributes/dictionary-drawer-settings Initializes dictionaries with sample data within the OnInspectorInit method. ```csharp [OnInspectorInit] private void CreateData() { IntMaterialLookup = new Dictionary() { { 1, ExampleHelper.GetMaterial() }, { 7, ExampleHelper.GetMaterial() }, }; StringStringDictionary = new Dictionary() { { "One", ExampleHelper.GetString() }, { "Seven", ExampleHelper.GetString() }, }; } ``` -------------------------------- ### Info Box Example Source: https://odininspector.com/attributes/list-drawer-settings-attribute Displays an informational message box in the inspector. This is often used to provide context or instructions. ```csharp [InfoBox("Lists can be made read-only in different ways.")] ``` -------------------------------- ### GUIColor with RGB and RGBA Color Strings Source: https://odininspector.com/attributes/guicolor-attribute Illustrates using GUIColor with RGB and RGBA color values specified as strings. ```csharp [GUIColor("RGB(0, 1, 0)")] public int Rgb; [GUIColor("RGBA(0, 1, 0, 0.5)")] public int Rgba; ``` -------------------------------- ### Abstract and Concrete Class Definitions Source: https://odininspector.com/attributes/type-drawer-settings-attribute Defines abstract and concrete classes that implement the interfaces, used for type filtering examples. ```csharp public abstract class Base : IBase { } public class Concrete : Base { } public class ConcreteGeneric : Base { } public abstract class BaseGeneric : IBase { } [CompilerGenerated] public class ConcreteGenerated : Base { } ``` -------------------------------- ### GUIColor with Named Colors Source: https://odininspector.com/attributes/guicolor-attribute Demonstrates applying GUIColor using predefined named colors. ```csharp [GUIColor("orange")] public int NamedColors; ``` -------------------------------- ### Basic Dictionary Serialization Source: https://odininspector.com/attributes/dictionary-drawer-settings Demonstrates how to serialize dictionaries by inheriting from SerializedMonoBehaviour. ```csharp [InfoBox("In order to serialize dictionaries, all we need to do is to inherit our class from SerializedMonoBehaviour.")] public Dictionary IntMaterialLookup; public Dictionary StringStringDictionary; ``` -------------------------------- ### Basic GUIColor Usage with RGBA Values Source: https://odininspector.com/attributes/guicolor-attribute Demonstrates applying GUIColor with direct RGBA float values to integer properties. ```csharp [GUIColor(0.3f, 0.8f, 0.8f, 1f)] public int ColoredInt1; [GUIColor(0.3f, 0.8f, 0.8f, 1f)] public int ColoredInt2; ``` -------------------------------- ### DisableIn Attribute Examples Source: https://odininspector.com/attributes/disable-in-attribute Demonstrates various uses of the DisableIn attribute to control field visibility based on prefab kind. ```csharp [DisableIn(PrefabKind.InstanceInScene)] public string InstanceInScene = "Instances of prefabs in scenes"; ``` ```csharp [DisableIn(PrefabKind.InstanceInPrefab)] public string InstanceInPrefab = "Instances of prefabs nested inside other prefabs"; ``` ```csharp [DisableIn(PrefabKind.Regular)] public string Regular = "Regular prefab assets"; ``` ```csharp [DisableIn(PrefabKind.Variant)] public string Variant = "Prefab variant assets"; ``` ```csharp [DisableIn(PrefabKind.NonPrefabInstance)] public string NonPrefabInstance = "Non-prefab component or gameobject instances in scenes"; ``` ```csharp [DisableIn(PrefabKind.PrefabInstance)] public string PrefabInstance = "Instances of regular prefabs, and prefab variants in scenes or nested in other prefabs"; ``` ```csharp [DisableIn(PrefabKind.PrefabAsset)] public string PrefabAsset = "Prefab assets and prefab variant assets"; ``` ```csharp [DisableIn(PrefabKind.PrefabInstanceAndNonPrefabInstance)] public string PrefabInstanceAndNonPrefabInstance = "Prefab Instances, as well as non-prefab instances"; ``` -------------------------------- ### ValueDropdown with Custom List and Options Source: https://odininspector.com/attributes/value-dropdown-attribute Shows how to use ValueDropdown with a custom list of MonoBehaviours and configure options like appending drawers and disabling GUI in appended drawers. ```csharp [ValueDropdown("FriendlyTextureSizes")] public int SomeSize2; ``` ```csharp [ValueDropdown("FriendlyTextureSizes", AppendNextDrawer = true, DisableGUIInAppendedDrawer = true)] public int SomeSize3; ``` ```csharp [ValueDropdown("GetListOfMonoBehaviours", AppendNextDrawer = true)] public MonoBehaviour SomeMonoBehaviour; ``` -------------------------------- ### Asset Selector with Expand All Menu Items Source: https://odininspector.com/attributes/asset-selector-attribute Illustrates expanding all menu items by default using ExpandAllMenuItems. ```csharp [AssetSelector(ExpandAllMenuItems = true)] public List ExpandAllMenuItems; ``` -------------------------------- ### Custom Title Bar Button Implementation Source: https://odininspector.com/attributes/list-drawer-settings-attribute Example implementation of a custom title bar button that logs the count of a list when clicked. ```csharp private void DrawRefreshButton() { if (SirenixEditorGUI.ToolbarButton(EditorIcons.Refresh)) { Debug.Log(this.CustomButtons.Count.ToString()); } } ``` -------------------------------- ### Applying HideMonoScript Attribute Source: https://odininspector.com/attributes/hide-mono-script-attribute Apply the HideMonoScript attribute to a class to hide its Script property in the inspector. This example shows how to hide a ScriptableObject reference. ```csharp [InfoBox("Click the pencil icon to open new inspector for these fields.")] public HideMonoScriptScriptableObject Hidden; // The script will also be hidden for the ShowMonoScript object if MonoScripts are hidden globally. public ShowMonoScriptScriptableObject Shown; [OnInspectorInit] private void CreateData() { Hidden = ExampleHelper.GetScriptableObject("Hidden"); Shown = ExampleHelper.GetScriptableObject("Shown"); } [OnInspectorDispose] private void CleanupData() { if (Hidden != null) Object.DestroyImmediate(Hidden); if (Shown != null) Object.DestroyImmediate(Shown); } ``` -------------------------------- ### Filtering Asset List by Asset Name Prefix Source: https://odininspector.com/attributes/asset-list-attribute Demonstrates filtering a list of GameObjects to include only those whose names start with a specific prefix. ```csharp [AssetList(AssetNamePrefix = "Rock")] [FoldoutGroup("Filtered AssetLists examples")] public List PrefabsStartingWithRock; ``` -------------------------------- ### Basic Asset Selector Usage Source: https://odininspector.com/attributes/asset-selector-attribute Demonstrates the basic usage of the AssetSelector attribute for single and multiple material selections. ```csharp [AssetSelector] public Material AnyAllMaterials; [AssetSelector] public Material[] ListOfAllMaterials; ``` -------------------------------- ### EnableGUIAttribute Usage Source: https://odininspector.com/attributes/enable-guiattribute Demonstrates how to use EnableGUIAttribute to enable a property's GUI. The first property is disabled by default, while the second is enabled using the attribute. ```csharp [ShowInInspector] public int GUIDisabledProperty { get { return 10; } } [ShowInInspector, EnableGUI] public int GUIEnabledProperty { get { return 10; } } ``` -------------------------------- ### Auto-Populating Asset List Source: https://odininspector.com/attributes/asset-list-attribute Shows how to use AssetList with AutoPopulate set to true to automatically populate the list when the Inspector is inspected. ```csharp [AssetList(AutoPopulate = true, Path = "Plugins/Sirenix/")] [FoldoutGroup("Filtered Odin ScriptableObjects", expanded: false)] public List AutoPopulatedWhenInspected; ``` -------------------------------- ### Basic Preview Field Source: https://odininspector.com/attributes/preview-field-attribute Demonstrates the basic usage of the PreviewField attribute for a regular object field. ```csharp [PreviewField] public Object RegularPreviewField; ``` -------------------------------- ### Conditional Field Visibility with ShowIn Attribute Source: https://odininspector.com/attributes/show-in-attribute Use the ShowIn attribute to control when a field is visible in the inspector. Each example demonstrates a different PrefabKind enum value. ```csharp [ShowIn(PrefabKind.InstanceInScene)] public string InstanceInScene = "Instances of prefabs in scenes"; [ShowIn(PrefabKind.InstanceInPrefab)] public string InstanceInPrefab = "Instances of prefabs nested inside other prefabs"; [ShowIn(PrefabKind.Regular)] public string Regular = "Regular prefab assets"; [ShowIn(PrefabKind.Variant)] public string Variant = "Prefab variant assets"; [ShowIn(PrefabKind.NonPrefabInstance)] public string NonPrefabInstance = "Non-prefab component or gameobject instances in scenes"; [ShowIn(PrefabKind.PrefabInstance)] public string PrefabInstance = "Instances of regular prefabs, and prefab variants in scenes or nested in other prefabs"; [ShowIn(PrefabKind.PrefabAsset)] public string PrefabAsset = "Prefab assets and prefab variant assets"; [ShowIn(PrefabKind.PrefabInstanceAndNonPrefabInstance)] public string PrefabInstanceAndNonPrefabInstance = "Prefab Instances, as well as non-prefab instances"; ``` -------------------------------- ### Basic Tab Grouping Source: https://odininspector.com/attributes/tab-group-attribute Demonstrates basic tab grouping for different categories of player properties. ```csharp [TabGroup("General")] public string playerName1; [TabGroup("General")] public int playerLevel1; [TabGroup("General")] public string playerClass1; [TabGroup("Stats")] public int strength1; [TabGroup("Stats")] public int dexterity1; [TabGroup("Stats")] public int intelligence1; [TabGroup("Quests")] public bool hasMainQuest1; [TabGroup("Quests")] public int mainQuestProgress1; [TabGroup("Quests")] public bool hasSideQuest1; [TabGroup("Quests")] public int sideQuestProgress1; ``` -------------------------------- ### Basic MinMaxSlider with Static Range Source: https://odininspector.com/attributes/min-max-slider-attribute Use this snippet to create a basic MinMaxSlider with predefined minimum and maximum values. ```csharp [MinMaxSlider(-10, 10)] public Vector2 MinMaxValueSlider = new Vector2(-7, -2); ``` -------------------------------- ### Basic Indent Attribute Usage Source: https://odininspector.com/attributes/indent-attribute Demonstrates how to use the Indent attribute with default and specified indentation levels. Use this to visually organize properties in the inspector. ```csharp [Title("Nicely organize your properties.")] [Indent] public int A; [Indent(2)] public int B; [Indent(3)] public int C; [Indent(4)] public int D; [Title("Using the Indent attribute")] [Indent] public int E; [Indent(0)] public int F; [Indent(-1)] public int G; ``` -------------------------------- ### Required Attribute with Custom Message Source: https://odininspector.com/attributes/required-attribute Shows how to provide a custom error message when a required property is missing. This example marks a Rigidbody property as required and specifies a custom message. ```csharp [Required("Custom error message.")] public Rigidbody MyRigidbody; ```