### Install NaughtyAttributes via openupm-cli Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Install the NaughtyAttributes package using the openupm-cli. Ensure you have openupm-cli installed and configured. ```bash openupm add com.dbrizov.naughtyattributes ``` -------------------------------- ### Install NaughtyAttributes via manifest.json Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Add the NaughtyAttributes package to your Unity project by including the git URL in your manifest.json file. This method allows direct installation from a GitHub repository. ```json "com.dbrizov.naughtyattributes": "https://github.com/dbrizov/NaughtyAttributes.git#upm" ``` -------------------------------- ### InfoBox Attribute for Warning Messages Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Use the InfoBox attribute to display warning messages in the Inspector. This example shows a warning type message. ```csharp public class NaughtyComponent : MonoBehaviour { [InfoBox("This is my float", EInfoBoxType.Warning)] public float myFloat; } ``` -------------------------------- ### InfoBox Attribute for Error Messages Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Use the InfoBox attribute to display error messages in the Inspector. This example shows an error type message. ```csharp public class NaughtyComponent : MonoBehaviour { [InfoBox("This is my vector", EInfoBoxType.Error)] public Vector3 myVector; } ``` -------------------------------- ### InfoBox Attribute for Normal Messages Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Use the InfoBox attribute to display informational messages in the Inspector. This example shows a normal type message. ```csharp public class NaughtyComponent : MonoBehaviour { [InfoBox("This is my int", EInfoBoxType.Normal)] public int myInt; } ``` -------------------------------- ### ShowAssetPreview for Thumbnail Previews Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use [ShowAssetPreview] to display a thumbnail preview of a Unity asset below the field. The size is configurable, with a default of 64x64 pixels. ```csharp using NaughtyAttributes; using UnityEngine; public class IconLibrary : MonoBehaviour { [ShowAssetPreview] // 64×64 default public Sprite defaultIcon; [ShowAssetPreview(128, 128)] public Sprite largeIcon; [ShowAssetPreview(96, 96)] public GameObject previewPrefab; } ``` -------------------------------- ### Layer Dropdown for Project Layers Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use the [Layer] attribute to create a dropdown for selecting project layers. It supports both string (layer name) and int (layer index) fields. ```csharp using NaughtyAttributes; using UnityEngine; public class ProjectileConfig : MonoBehaviour { [Layer] public string targetLayerName; // stores the layer name [Layer] public int ignoreLayerIndex; // stores the layer index void Awake() { int mask = LayerMask.GetMask(targetLayerName); Physics.IgnoreLayerCollision(gameObject.layer, ignoreLayerIndex, true); } } ``` -------------------------------- ### ProgressBar Visualization Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use the [ProgressBar] attribute to display an int or float field as a labeled, colored progress bar. The maximum value can be a literal or a dynamic reference. ```csharp using NaughtyAttributes; using UnityEngine; public class Hero : MonoBehaviour { // Literal max value. [ProgressBar("Health", 100f, EColor.Red)] public int health = 75; [ProgressBar("Mana", 200f, EColor.Blue)] public float mana = 120f; // Dynamic max – references a field named 'maxStamina'. public float maxStamina = 200f; [ProgressBar("Stamina", "maxStamina", EColor.Green)] public float stamina = 180f; } ``` -------------------------------- ### MinValue and MaxValue Attributes for Clamping Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Clamp integer and float fields within a specified range using the MinValue and MaxValue attributes. Only MinValue is required to set a lower bound, and only MaxValue for an upper bound. ```csharp public class NaughtyComponent : MonoBehaviour { [MinValue(0), MaxValue(10)] public int myInt; [MinValue(0.0f)] public float myFloat; } ``` -------------------------------- ### Tag Dropdown for Project Tags Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use the [Tag] attribute to replace a raw string field with a dropdown of all project tags defined in Unity's project settings. ```csharp using NaughtyAttributes; using UnityEngine; public class PickupDetector : MonoBehaviour { [Tag] public string pickupTag; [Tag] public string enemyTag; void OnTriggerEnter(Collider other) { if (other.CompareTag(pickupTag)) Debug.Log("Pickup!"); if (other.CompareTag(enemyTag)) Debug.Log("Enemy touched!"); } } ``` -------------------------------- ### ShowAssetPreview Attribute for Texture Previews Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The [ShowAssetPreview] attribute displays a texture preview for Sprites or Prefabs directly in the inspector. You can specify the preview dimensions. ```csharp public class NaughtyComponent : MonoBehaviour { [ShowAssetPreview] public Sprite sprite; [ShowAssetPreview(128, 128)] public GameObject prefab; } ``` -------------------------------- ### Scene Dropdown for Build Settings Source: https://context7.com/dbrizov/naughtyattributes/llms.txt The [Scene] attribute replaces string or int fields with a dropdown populated by scenes in the build settings. It supports scene names (string) and build indices (int). ```csharp using NaughtyAttributes; using UnityEngine; using UnityEngine.SceneManagement; public class GameFlowManager : MonoBehaviour { [Scene] public string mainMenuScene; // scene name [Scene] public int gameplaySceneIndex; // build index public void GoToMainMenu() => SceneManager.LoadScene(mainMenuScene); public void GoToGameplay() => SceneManager.LoadScene(gameplaySceneIndex); } ``` -------------------------------- ### EnableIf with Multiple Conditions Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md You can specify multiple conditions for the [EnableIf] attribute using logical operators like AND or OR. ```csharp public class NaughtyComponent : MonoBehaviour { public bool flag0; public bool flag1; [EnableIf(EConditionOperator.And, "flag0", "flag1")] public int enabledIfAll; [EnableIf(EConditionOperator.Or, "flag0", "flag1")] public int enabledIfAny; } ``` -------------------------------- ### ShowIf Attribute for Conditional Display Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Conditionally show fields based on the state of a boolean field or the return value of a method using [ShowIf]. ```csharp public class NaughtyComponent : MonoBehaviour { public bool showInt; [ShowIf("showInt")] public int myInt; [ShowIf("AlwaysShow")] public float myFloat; [ShowIf("NeverShow")] public Vector3 myVector; public bool AlwaysShow() { return true; } public bool NeverShow => false; } ``` ```csharp public class NaughtyComponent : MonoBehaviour { public bool flag0; public bool flag1; [ShowIf(EConditionOperator.And, "flag0", "flag1")] public int showIfAll; [ShowIf(EConditionOperator.Or, "flag0", "flag1")] public int showIfAny; } ``` -------------------------------- ### AllowNesting for Nested Serializable Classes Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use [AllowNesting] to enable NaughtyAttributes on fields within nested serializable classes or structs. This is necessary for meta attributes and some drawer attributes to function correctly in nested contexts. ```csharp using NaughtyAttributes; using UnityEngine; public class PlayerController : MonoBehaviour { public WeaponConfig weapon; } [System.Serializable] public struct WeaponConfig { public bool isAutomatic; // Without [AllowNesting], EnableIf would be silently ignored here. [EnableIf("isAutomatic")] [AllowNesting] public float fireRate; [ShowIf("isAutomatic")] [AllowNesting] public int magazineSize; } ``` -------------------------------- ### ShowIf Attribute with Multiple Conditions Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Combine multiple conditions using EConditionOperator.And or EConditionOperator.Or to control field visibility. All specified conditions must be met for 'And', while any one condition is sufficient for 'Or'. ```csharp public class NaughtyComponent : MonoBehaviour { public bool flag0; public bool flag1; [ShowIf(EConditionOperator.And, "flag0", "flag1")] public int showIfAll; [ShowIf(EConditionOperator.Or, "flag0", "flag1")] public int showIfAny; } ``` -------------------------------- ### Clamp Numeric Fields with MinValue and MaxValue Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use MinValue and MaxValue attributes to set floor and ceiling constraints for int and float fields. These attributes display errors in the inspector when constraints are violated and can be used together on the same field. ```csharp using NaughtyAttributes; using UnityEngine; public class ProjectileSettings : MonoBehaviour { [MinValue(0f)] public float speed = 20f; [MinValue(1), MaxValue(100)] public int damage = 25; [MinValue(0f), MaxValue(1f)] public float accuracy = 0.85f; } ``` -------------------------------- ### ProgressBar Attribute for Mana Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Use the ProgressBar attribute to display a progress bar in the Inspector for a mana value. Specify the max value and color. ```csharp public class NaughtyComponent : MonoBehaviour { [ProgressBar("Mana", 100, EColor.Blue)] public int mana = 25; } ``` -------------------------------- ### InfoBox Attribute for Contextual Messages Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Renders a Unity-style info/warning/error box above the annotated field. `EInfoBoxType` values are `Normal`, `Warning`, and `Error`. `AllowMultiple = true`. ```csharp using NaughtyAttributes; using UnityEngine; public class NetworkConfig : MonoBehaviour { [InfoBox("Must match the server configuration exactly.", EInfoBoxType.Warning)] public string serverAddress = "127.0.0.1"; [InfoBox("Leave 0 for dynamic allocation.")] public int port = 0; [InfoBox("Enabling this disables encryption!", EInfoBoxType.Error)] public bool debugMode; } ``` -------------------------------- ### Conditionally Show Fields with ShowIf Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use ShowIf to make fields visible only when specified conditions are true. Conditions can be boolean members, enum comparisons, or combined with operators. ```csharp using NaughtyAttributes; using UnityEngine; public class WeaponConfig : MonoBehaviour { public bool isRanged; public WeaponType weaponType; [ShowIf("isRanged")] public float projectileSpeed; [ShowIf("isRanged")] public int maxAmmo; // Shown only when exactly the Sniper type is selected. [ShowIf("weaponType", WeaponType.Sniper)] public float scopeZoom; // Multi-condition: shown when both flags are true. [ShowIf(EConditionOperator.And, "isRanged", "HasScope")] public float zoomSensitivity; bool HasScope => weaponType == WeaponType.Sniper || weaponType == WeaponType.AssaultRifle; } public enum WeaponType { Sword, AssaultRifle, Sniper, Shotgun } ``` -------------------------------- ### ReorderableList for Arrays and Lists Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Renders array and List fields as Unity's reorderable list UI, enabling drag-to-reorder and +/- buttons. This attribute can be combined with others like ShowIf. ```csharp using NaughtyAttributes; using UnityEngine; using System.Collections.Generic; public class WaypointRoute : MonoBehaviour { [ReorderableList] public Transform[] waypoints; [ReorderableList] public List checkpointLabels; // Can combine with other attributes. [ReorderableList] [ShowIf("enabled")] public int[] priorityWeights; } ``` -------------------------------- ### Dropdown Attribute for Integer Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Use the Dropdown attribute to create a dropdown list for selecting an integer value from a predefined array. ```csharp public class NaughtyComponent : MonoBehaviour { [Dropdown("intValues")] public int intValue; private int[] intValues = new int[] { 1, 2, 3, 4, 5 }; } ``` -------------------------------- ### AllowNesting for Nested Serializable Structs Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Use the AllowNesting attribute when meta attributes need to work within serializable nested structs or classes. This explicitly enables nesting for attributes applied to fields within nested structures. ```csharp public class NaughtyComponent : MonoBehaviour { public MyStruct myStruct; } [System.Serializable] public struct MyStruct { public bool enableFlag; [EnableIf("enableFlag")] [AllowNesting] // Because it's nested we need to explicitly allow nesting public int integer; } ``` -------------------------------- ### InputAxis Attribute for Input Axis Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Use the InputAxis attribute to provide a dropdown for selecting an input axis defined in Unity's Input Manager. ```csharp public class NaughtyComponent : MonoBehaviour { [InputAxis] public string inputAxis; } ``` -------------------------------- ### Scene Attribute for Scene Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Use the [Scene] attribute to create a dropdown for selecting scene names or indices in the inspector. ```csharp public class NaughtyComponent : MonoBehaviour { [Scene] public string bootScene; // scene name [Scene] public int tutorialScene; // scene index } ``` -------------------------------- ### Dropdown Attribute for String Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Use the Dropdown attribute to create a dropdown list for selecting a string value from a predefined list. ```csharp public class NaughtyComponent : MonoBehaviour { [Dropdown("StringValues")] public string stringValue; private List StringValues { get { return new List() { "A", "B", "C", "D", "E" }; } } } ``` -------------------------------- ### ShowNativeProperty for Read-Only Properties Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Displays a C# property getter's value as a read-only label in the inspector. Supports various primitive types, Vector types, Color, Bounds, Rect, and UnityEngine.Object. ```csharp using NaughtyAttributes; using UnityEngine; using System.Collections.Generic; public class Inventory : MonoBehaviour { public List items = new List(); [ShowNativeProperty] private int ItemCount => items.Count; [ShowNativeProperty] private string LastAdded => items.Count > 0 ? items[^1] : "none"; [ShowNativeProperty] private Transform RootTransform => transform.root; } ``` -------------------------------- ### Dropdown Attribute for Vector3 Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Use the Dropdown attribute with a method returning a DropdownList to select a Vector3 value. ```csharp public class NaughtyComponent : MonoBehaviour { [Dropdown("GetVectorValues")] public Vector3 vectorValue; private DropdownList GetVectorValues() { return new DropdownList() { { "Right", Vector3.right }, { "Left", Vector3.left }, { "Up", Vector3.up }, { "Down", Vector3.down }, { "Forward", Vector3.forward }, { "Back", Vector3.back } }; } } ``` -------------------------------- ### ProgressBar Attribute for Stamina Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Use the ProgressBar attribute to display a progress bar in the Inspector for a stamina value. Specify the max value and color. ```csharp public class NaughtyComponent : MonoBehaviour { [ProgressBar("Stamina", 200, EColor.Green)] public int stamina = 150; } ``` -------------------------------- ### Custom Input Validation with ValidateInput Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Implement custom validation logic using the ValidateInput attribute, which calls a named method returning a bool. This method receives the current field value and returns true if valid. An optional message string can override the default error text. Validation fires on every inspector change. ```csharp using NaughtyAttributes; using UnityEngine; public class SaveConfig : MonoBehaviour { [ValidateInput("IsNotEmpty", "Save name must not be empty.")] public string saveName = "Player1"; [ValidateInput("IsPositive")] public int maxSaves = 5; [ValidateInput("IsAssignedAndActive")] public GameObject saveIconPrefab; private bool IsNotEmpty(string value) => !string.IsNullOrEmpty(value); private bool IsPositive(int value) => value > 0; private bool IsAssignedAndActive(GameObject go) => go != null && go.activeSelf; } ``` -------------------------------- ### Custom Inspector Integration with NaughtyInspector Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Inherit from NaughtyInspector and use NaughtyEditorGUI.PropertyField_Layout instead of EditorGUILayout.PropertyField to preserve full NaughtyAttributes compatibility within a hand-written Editor class. This allows custom drawing while keeping all attribute behaviors active. ```csharp // Runtime component using NaughtyAttributes; using UnityEngine; public class Boss : MonoBehaviour { [ProgressBar("HP", 500, EColor.Red)] public int hp = 500; [ReorderableList] public string[] phaseNames; [Button("Trigger Phase Change")] private void NextPhase() => Debug.Log("Phase changed!"); [ShowNativeProperty] private string CurrentPhase => phaseNames.Length > 0 ? phaseNames[0] : "none"; } // Custom editor that preserves all NaughtyAttributes behavior #if UNITY_EDITOR using NaughtyAttributes.Editor; using UnityEditor; using UnityEngine; [CustomEditor(typeof(Boss))] public class BossEditor : NaughtyInspector { public override void OnInspectorGUI() { // Draw a custom header above the NaughtyAttributes inspector. EditorGUILayout.HelpBox("Boss Inspector — all NaughtyAttributes are active.", MessageType.Info); // Draw all serialized properties with full NaughtyAttributes support. DrawSerializedProperties(); // Draw non-serialized fields, native properties, and buttons. DrawNonSerializedFields(); DrawNativeProperties(); DrawButtons(); } } #endif ``` -------------------------------- ### Expandable Attribute for Inline ScriptableObject Editing Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Adds an expand/collapse toggle next to a ScriptableObject reference field for direct editing in the parent inspector. Pass `isReadonly: true` to prevent edits. ```csharp using NaughtyAttributes; using UnityEngine; [CreateAssetMenu(menuName = "Game/WeaponStats")] public class WeaponStats : ScriptableObject { public float damage; public float range; public int clipSize; } public class Weapon : MonoBehaviour { // Editable inline. [Expandable] public WeaponStats stats; // Read-only inline preview. [Expandable(isReadonly: true)] public WeaponStats defaultStats; } ``` -------------------------------- ### Dropdown Attribute for Integer, String, and Vector3 Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Use the Dropdown attribute to create dropdowns for selecting values from arrays, lists, or custom methods returning DropdownList. Supports various data types. ```csharp public class NaughtyComponent : MonoBehaviour { [Dropdown("intValues")] public int intValue; [Dropdown("StringValues")] public string stringValue; [Dropdown("GetVectorValues")] public Vector3 vectorValue; private int[] intValues = new int[] { 1, 2, 3, 4, 5 }; private List StringValues { get { return new List() { "A", "B", "C", "D", "E" }; } } private DropdownList GetVectorValues() { return new DropdownList() { { "Right", Vector3.right }, { "Left", Vector3.left }, { "Up", Vector3.up }, { "Down", Vector3.down }, { "Forward", Vector3.forward }, { "Back", Vector3.back } }; } } ``` -------------------------------- ### Foldout for Collapsible Field Groups Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Groups fields under a collapsible foldout header. The expanded or collapsed state is persisted per-object instance using EditorPrefs. ```csharp using NaughtyAttributes; using UnityEngine; public class AudioConfig : MonoBehaviour { [Foldout("Music")] public AudioClip menuMusic; [Foldout("Music")] public float musicVolume = 0.8f; [Foldout("SFX")] public AudioClip jumpSound; [Foldout("SFX")] public AudioClip landSound; [Foldout("SFX")] public float sfxVolume = 1.0f; } ``` -------------------------------- ### SortingLayer Dropdown for Project Layers Source: https://context7.com/dbrizov/naughtyattributes/llms.txt The [SortingLayer] attribute populates a dropdown with project sorting layers. It works with both string (layer name) and int (layer ID) fields. ```csharp using NaughtyAttributes; using UnityEngine; public class RendererConfig : MonoBehaviour { [SortingLayer] public string layerName; [SortingLayer] public int layerId; void Awake() { GetComponent().sortingLayerName = layerName; } } ``` -------------------------------- ### Conditionally Hide Fields with HideIf Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use HideIf to hide fields when specified conditions are true. This is the inverse of ShowIf and also applies to [Button]-decorated methods. ```csharp using NaughtyAttributes; using UnityEngine; public class WeaponConfig : MonoBehaviour { public bool isRanged; // Hidden when the weapon is ranged (visible for melee). [HideIf("isRanged")] public float swingRadius; // ... other methods and fields } public enum WeaponType { Sword, AssaultRifle, Sniper, Shotgun } ``` -------------------------------- ### ResizableTextArea Attribute for Expandable Text Input Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Unlike Unity's default TextArea, the ResizableTextArea attribute provides a text area that can be resized by the user, allowing for easier viewing and editing of longer text content. ```csharp public class NaughtyComponent : MonoBehaviour { [ResizableTextArea] public string resizableTextArea; } ``` -------------------------------- ### EnableIf Attribute for Conditional Enabling Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The [EnableIf] attribute enables a field only when a specified condition is met. Conditions can be boolean fields, methods returning bool, or properties. ```csharp public class NaughtyComponent : MonoBehaviour { public bool enableMyInt; [EnableIf("enableMyInt")] public int myInt; [EnableIf("Enabled")] public float myFloat; [EnableIf("NotEnabled")] public Vector3 myVector; public bool Enabled() { return true; } public bool NotEnabled => false; } ``` -------------------------------- ### InputAxis Attribute for Input Manager Axes Dropdown Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Replaces a raw string field with a dropdown listing all axes defined in the project's Input Manager. Useful for ensuring correct axis names are used. ```csharp using NaughtyAttributes; using UnityEngine; public class PlayerInput : MonoBehaviour { [InputAxis] public string horizontalAxis; // e.g. "Horizontal" [InputAxis] public string verticalAxis; // e.g. "Vertical" [InputAxis] public string fireAxis; // e.g. "Fire1" void Update() { float h = Input.GetAxis(horizontalAxis); float v = Input.GetAxis(verticalAxis); transform.Translate(new Vector3(h, 0, v) * Time.deltaTime * 5f); } } ``` -------------------------------- ### Button Attribute for Invoking Methods Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Mark a method with the Button attribute to make it appear as a clickable button in the Unity Inspector. This attribute works for both instance and static methods, and allows for custom button text. ```csharp public class NaughtyComponent : MonoBehaviour { [Button] private void MethodOne() { } [Button("Button Text")] private void MethodTwo() { } } ``` -------------------------------- ### ShowNativeProperty Attribute for C# Properties Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Use [ShowNativeProperty] to display native C# properties in the inspector. It supports specific data types and appears after non-serialized fields. ```csharp public class NaughtyComponent : MonoBehaviour { public List transforms; [ShowNativeProperty] public int TransformsCount => transforms.Count; } ``` -------------------------------- ### SortingLayer Attribute for Sorting Layer Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Use the [SortingLayer] attribute to provide a dropdown for selecting a sorting layer by name or ID in the inspector. ```csharp public class NaughtyComponent : MonoBehaviour { [SortingLayer] public string layerName; [SortingLayer] public int layerId; } ``` -------------------------------- ### Conditionally Enable Fields with EnableIf Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use EnableIf to make fields editable only when specified conditions (boolean fields, properties, methods, or enum comparisons) are met. Multiple conditions can be combined with AND or OR operators. ```csharp using NaughtyAttributes; using UnityEngine; public class VehicleController : MonoBehaviour { public bool hasNitro; public bool engineRunning; // Editable only when both flags are true. [EnableIf(EConditionOperator.And, "hasNitro", "engineRunning")] public float nitroBoost = 2.5f; // Editable when either flag is true. [EnableIf(EConditionOperator.Or, "hasNitro", "engineRunning")] public float topSpeed = 120f; // Enum comparison: editable only when driveMode == DriveMode.Sport. public DriveMode driveMode; [EnableIf("driveMode", DriveMode.Sport)] public float sportTorque = 400f; } public enum DriveMode { Normal, Sport, Eco } ``` -------------------------------- ### ShowNonSerializedField for Non-Serialized Fields Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Marks a private, non-serialized field to display its value as a read-only label in the inspector. Static fields update at compile time, while non-static fields update after entering Play mode. ```csharp using NaughtyAttributes; using UnityEngine; public class DebugStats : MonoBehaviour { [ShowNonSerializedField] private int frameCount; [ShowNonSerializedField] private const float GravityConst = 9.81f; [ShowNonSerializedField] private static readonly string BuildTag = "alpha-1.2"; void Update() => frameCount++; } ``` -------------------------------- ### Dropdown Attribute for Inspector Dropdowns Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Binds a serialized field to a source (field, property, or method) that returns a typed array, List, or DropdownList. The resolved member can be private and works within nested serializable classes. ```csharp using NaughtyAttributes; using UnityEngine; using System.Collections.Generic; public class SpawnManager : MonoBehaviour { // Backed by an array field – display labels equal the values. [Dropdown("spawnCounts")] public int spawnCount; private int[] spawnCounts = { 1, 5, 10, 20, 50 }; // Backed by a property returning List. [Dropdown("DifficultyNames")] public string difficulty; private List DifficultyNames => new List { "Easy", "Normal", "Hard", "Nightmare" }; // Backed by a method returning DropdownList with custom labels. [Dropdown("GetSpawnOffsets")] public Vector3 spawnOffset; private DropdownList GetSpawnOffsets() { return new DropdownList { { "Center", Vector3.zero }, { "Forward 5", Vector3.forward * 5f }, { "Right 5", Vector3.right * 5f }, }; } } ``` -------------------------------- ### Override Field Display Name with Label Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use the Label attribute to provide a custom display name for a field in the inspector, without renaming the actual field. ```csharp using NaughtyAttributes; using UnityEngine; public class MovementConfig : MonoBehaviour { [Label("Walk Speed (m/s)")] public float walkSpeed = 3f; [Label("Sprint Multiplier ×")] public float sprintMultiplierXXX = 2f; // long name hidden behind label [Label("RGB Tint")] public Vector3 colorTintVector; } ``` -------------------------------- ### MinMaxSlider for Vector2 Range Source: https://context7.com/dbrizov/naughtyattributes/llms.txt The [MinMaxSlider] attribute creates a dual-handle range slider for Vector2 fields. It allows defining fixed minimum and maximum values for the slider. ```csharp using NaughtyAttributes; using UnityEngine; public class EnemySpawner : MonoBehaviour { [MinMaxSlider(0f, 30f)] public Vector2 spawnInterval = new Vector2(5f, 15f); [MinMaxSlider(1, 20)] public Vector2 groupSize = new Vector2(2f, 8f); float GetNextDelay() => Random.Range(spawnInterval.x, spawnInterval.y); int GetGroupCount() => (int)Random.Range(groupSize.x, groupSize.y + 1); } ``` -------------------------------- ### ShowIf Attribute with Single Condition Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Use the ShowIf attribute to conditionally draw a field based on a boolean field or method. The condition can be a public field or a public method that returns a boolean. ```csharp public class NaughtyComponent : MonoBehaviour { public bool showInt; [ShowIf("showInt")] public int myInt; [ShowIf("AlwaysShow")] public float myFloat; [ShowIf("NeverShow")] public Vector3 myVector; public bool AlwaysShow() { return true; } public bool NeverShow => false; } ``` -------------------------------- ### RequiredType Attribute for Component and Interface Checks Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Verify that a GameObject or Component has a specific component or implements a required interface using the RequiredType attribute. It supports checking for multiple types and optionally disabling info messages. ```csharp public class NaughtyComponent : MonoBehaviour { [RequiredType(typeof(Rigidbody))] public GameObject gameObjectMustHaveRigidbody; [RequiredType(typeof(Rigidbody))] public Transform transformMustHaveRigidbody; [RequiredType(typeof(IRequiredTypeTestInterface))] public GameObject gameObjectMustHaveInterface; [RequiredType(typeof(RequiredTypeTestTestObject))] public GameObject gameObjectMustHaveComponent; [RequiredType(showInfoMessageWhenEmpty: false, typeof(IRequiredTypeTestInterface))] public GameObject shouldNotShowInfoMessageWhenEmpty; [RequiredType(typeof(IRequiredTypeTestInterface), typeof(IRequiredTypeTestInterface2))] public GameObject gameObjectMustHaveMultipleType; [RequiredType(typeof(RequiredTypeTestTestObject))] public RequiredTypeTest componentMustHaveAnotherComponent; } ``` -------------------------------- ### HorizontalLine Attribute for Decorative Separators Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Draws a colored horizontal rule above the annotated field. Height defaults to 2 px and color to EColor.Gray. `AllowMultiple = true` allows stacking. ```csharp using NaughtyAttributes; using UnityEngine; public class UIConfig : MonoBehaviour { [HorizontalLine(color: EColor.Red)] public Color primaryColor; [HorizontalLine(3f, EColor.Blue)] public Color secondaryColor; [HorizontalLine] // default: 2 px, gray public float animationSpeed; } ``` -------------------------------- ### ResizableTextArea for Auto-Growing Text Source: https://context7.com/dbrizov/naughtyattributes/llms.txt The [ResizableTextArea] attribute provides an auto-growing multiline text field that expands vertically to fit its content, replacing the need for manual scrolling. ```csharp using NaughtyAttributes; using UnityEngine; public class QuestData : MonoBehaviour { [ResizableTextArea] public string questDescription; [ResizableTextArea] public string completionDialogue; } ``` -------------------------------- ### ProgressBar Attribute for Health Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Use the ProgressBar attribute to display a progress bar in the Inspector for a health value. Specify the max value and color. ```csharp public class NaughtyComponent : MonoBehaviour { [ProgressBar("Health", 300, EColor.Red)] public int health = 250; } ``` -------------------------------- ### Foldout Attribute for Collapsible Groups Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The [Foldout] attribute creates a collapsible foldout group in the inspector, allowing you to organize fields and reduce clutter. ```csharp public class NaughtyComponent : MonoBehaviour { [Foldout("Integers")] public int firstInt; [Foldout("Integers")] public int secondInt; } ``` -------------------------------- ### EnumFlags Attribute for Multi-Select Checkbox Dropdowns Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Replaces the standard enum popup with a multi-select dropdown for [Flags] enums, allowing any combination of flag bits to be set. The field type must be a [Flags] enum. ```csharp using NaughtyAttributes; using UnityEngine; using System; [Flags] public enum StatusEffect { None = 0, Burning = 1, Frozen = 2, Stunned = 4, Poisoned = 8 } public class Character : MonoBehaviour { [EnumFlags] public StatusEffect activeEffects; bool IsBurning => (activeEffects & StatusEffect.Burning) != 0; bool IsDisabled => (activeEffects & (StatusEffect.Frozen | StatusEffect.Stunned)) != 0; } ``` -------------------------------- ### Expandable Attribute for Scriptable Objects Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Use the Expandable attribute to make ScriptableObject fields expandable in the inspector, allowing for inline editing of their properties. ```csharp public class NaughtyComponent : MonoBehaviour { [Expandable] public ScriptableObject scriptableObject; } ``` -------------------------------- ### BoxGroup for Grouping Fields in Boxes Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Groups related fields within a bordered box with an optional header label. Fields without a BoxGroup are rendered before any groups. Use an unnamed BoxGroup for an unlabeled box. ```csharp using NaughtyAttributes; using UnityEngine; public class CharacterStats : MonoBehaviour { [BoxGroup("Combat")] public int attackPower; [BoxGroup("Combat")] public float critChance; [BoxGroup("Defense")] public int armor; [BoxGroup("Defense")] public float dodgeChance; // Unnamed box. [BoxGroup] public Transform weaponSocket; [BoxGroup] public Transform shieldSocket; public string characterName; // outside all groups – rendered first } ``` -------------------------------- ### ProgressBar Attribute for Visual Progress Display Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The ProgressBar attribute displays a progress bar in the inspector for a given field, showing its current value relative to a maximum value. It supports custom labels and colors. ```csharp public class NaughtyComponent : MonoBehaviour { [ProgressBar("Health", 300, EColor.Red)] public int health = 250; [ProgressBar("Mana", 100, EColor.Blue)] public int mana = 25; [ProgressBar("Stamina", 200, EColor.Green)] public int stamina = 150; } ``` -------------------------------- ### CurveRange for Constrained AnimationCurves Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use [CurveRange] to constrain an AnimationCurve field within a defined bounding rectangle and tint the curve editor with a custom color. Constructor overloads allow specifying bounds and color in various ways. ```csharp using NaughtyAttributes; using UnityEngine; public class TurretController : MonoBehaviour { // Curve must stay within X:[0,10], Y:[0,1]; drawn in green (default). [CurveRange(0f, 0f, 10f, 1f)] public AnimationCurve accuracyOverTime; // Curve bounded to unit square, tinted orange. [CurveRange(EColor.Orange)] public AnimationCurve heatDissipation; // Full explicit bounds + color. [CurveRange(-1f, -1f, 1f, 1f, EColor.Red)] public AnimationCurve recoilCurve; float GetAccuracy(float elapsed) => accuracyOverTime.Evaluate(elapsed); } ``` -------------------------------- ### Required Attribute for Non-Null References Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Ensure that reference type fields are not null using the Required attribute. You can also provide a custom error message. ```csharp public class NaughtyComponent : MonoBehaviour { [Required] public Transform myTransform; [Required("Custom required text")] public GameObject myGameObject; } ``` -------------------------------- ### Layer Attribute for Layer Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The Layer attribute allows you to select a layer via a dropdown interface, either by layer name or layer index. ```csharp public class NaughtyComponent : MonoBehaviour { [Layer] public string layerName; [Layer] public int layerIndex; } ``` -------------------------------- ### Conditionally Disable Fields with DisableIf Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use DisableIf to make fields non-editable when specified conditions are met. This is the inverse of EnableIf and also applies to methods decorated with [Button]. ```csharp using NaughtyAttributes; using UnityEngine; public class VehicleController : MonoBehaviour { public bool engineRunning; // Disabled when the engine is running (opposite of EnableIf). [DisableIf("engineRunning")] public float fuelCapacity = 60f; // ... other methods and fields } public enum DriveMode { Normal, Sport, Eco } ``` -------------------------------- ### OnValueChanged Attribute for Callback Execution Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Execute a callback method whenever a field's value is changed in the inspector using the OnValueChanged attribute. Note that this does not trigger for runtime value changes. ```csharp public class NaughtyComponent : MonoBehaviour { [OnValueChanged("OnValueChangedCallback")] public int myInt; private void OnValueChangedCallback() { Debug.Log(myInt); } } ``` -------------------------------- ### Invoke Callback on Field Change with OnValueChanged Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use OnValueChanged to execute a specified method when a field's value is changed in the inspector. The callback method can be parameterless or accept a single parameter of the field's type. ```csharp using NaughtyAttributes; using UnityEngine; public class DayNightCycle : MonoBehaviour { [OnValueChanged("ApplyTimeOfDay")] public float timeOfDay; // 0–24 [OnValueChanged("RebuildGradient")] [OnValueChanged("LogColorChange")] public Color skyColor = Color.cyan; private void ApplyTimeOfDay() { float angle = (timeOfDay / 24f) * 360f; RenderSettings.skybox.SetFloat("_Rotation", angle); } private void RebuildGradient() { /* update gradient texture */ } private void LogColorChange() => Debug.Log($"Sky color → {skyColor}"); } ``` -------------------------------- ### AnimatorParam for Animator Controller Parameters Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use [AnimatorParam] to replace raw string or int fields with a dropdown populated from a referenced Animator component. An optional second argument can filter parameters by type (Float, Int, Bool, Trigger). ```csharp using NaughtyAttributes; using UnityEngine; public class EnemyAI : MonoBehaviour { public Animator animator; // Shows all parameters from 'animator' as a dropdown. [AnimatorParam("animator")] public string speedParam; // Shows only Float parameters. [AnimatorParam("animator", AnimatorControllerParameterType.Float)] public string blendParam; // Hash variant – shows only Int parameters, stores the hash directly. [AnimatorParam("animator", AnimatorControllerParameterType.Int)] public int stateHash; void Update() { animator.SetFloat(speedParam, 3.5f); animator.SetFloat(blendParam, 0.8f); } } ``` -------------------------------- ### ShowNonSerializedField Attribute for Non-Serialized Fields Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The [ShowNonSerializedField] attribute makes non-serialized fields visible in the inspector. Static non-serialized fields are updated at compile time, while non-static ones update after entering Play mode. ```csharp public class NaughtyComponent : MonoBehaviour { [ShowNonSerializedField] private int myInt = 10; [ShowNonSerializedField] private const float PI = 3.14159f; [ShowNonSerializedField] private static readonly Vector3 CONST_VECTOR = Vector3.one; } ``` -------------------------------- ### Render Fields as Non-Editable with ReadOnly Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use the ReadOnly attribute to display a field in the inspector as greyed-out and non-editable. This is useful for showing computed or runtime data. ```csharp using NaughtyAttributes; using UnityEngine; public class RuntimeInfo : MonoBehaviour { [ReadOnly] public string sessionId; [ReadOnly] public Vector3 spawnPosition; [ReadOnly] public int deathCount; void Awake() { sessionId = System.Guid.NewGuid().ToString(); spawnPosition = transform.position; } } ``` -------------------------------- ### HideIf Attribute for Conditional Hiding Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Conditionally hide fields based on the state of a boolean field or the return value of a method using [HideIf]. ```csharp public class NaughtyComponent : MonoBehaviour { public bool hideInt; [HideIf("hideInt")] public int myInt; [HideIf("AlwaysHide")] public float myFloat; [HideIf("NeverHide")] public Vector3 myVector; public bool AlwaysHide() { return true; } public bool NeverHide => false; } ``` ```csharp public class NaughtyComponent : MonoBehaviour { public bool flag0; public bool flag1; [HideIf(EConditionOperator.And, "flag0", "flag1")] public int hideIfAll; [HideIf(EConditionOperator.Or, "flag0", "flag1")] public int hideIfAny; } ``` -------------------------------- ### InfoBox Attribute for Displaying Information Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The InfoBox attribute displays a message box in the inspector, which can be used to provide additional information, warnings, or errors related to a field. Supports different info box types. ```csharp public class NaughtyComponent : MonoBehaviour { [InfoBox("This is my int", EInfoBoxType.Normal)] public int myInt; [InfoBox("This is my float", EInfoBoxType.Warning)] public float myFloat; [InfoBox("This is my vector", EInfoBoxType.Error)] public Vector3 myVector; } ``` -------------------------------- ### Button Attribute for Inspector Buttons Source: https://context7.com/dbrizov/naughtyattributes/llms.txt Use the Button attribute to add clickable buttons to the inspector that call methods. Customize button labels and enable modes (Always, Editor, Playmode). Supports static, coroutine, and regular methods. ```csharp using NaughtyAttributes; using UnityEngine; using System.Collections; public class LevelManager : MonoBehaviour { public int score; // Always enabled, label = "ResetScore". [Button] private void ResetScore() => score = 0; // Custom label, only active in the Editor (not in Play mode). [Button("Add 100 Points", EButtonEnableMode.Editor)] private void AddTestPoints() => score += 100; // Only callable during Play mode; runs as a coroutine. [Button("Count Up (5s)", EButtonEnableMode.Playmode)] private IEnumerator CountUp() { for (int i = 0; i < 5; i++) { score++; yield return new WaitForSeconds(1f); } } } ``` -------------------------------- ### AnimatorParam Attribute for Animator Parameters Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The AnimatorParam attribute provides a dropdown interface in the inspector to select Animator parameters. It can be used for both integer hash values and string parameter names. ```csharp public class NaughtyComponent : MonoBehaviour { public Animator someAnimator; [AnimatorParam("someAnimator")] public int paramHash; [AnimatorParam("someAnimator")] public string paramName; } ``` -------------------------------- ### Tag Attribute for Tag Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The [Tag] attribute allows you to select a tag from a dropdown list directly in the inspector. ```csharp public class NaughtyComponent : MonoBehaviour { [Tag] public string tagField; } ``` -------------------------------- ### DisableIf Attribute for Conditional Disabling Source: https://github.com/dbrizov/naughtyattributes/blob/master/Assets/NaughtyAttributes/README.html Conditionally disable fields based on the state of a boolean field or the return value of a method using [DisableIf]. ```csharp public class NaughtyComponent : MonoBehaviour { public bool disableMyInt; [DisableIf("disableMyInt")] public int myInt; [DisableIf("Disabled")] public float myFloat; [DisableIf("NotDisabled")] public Vector3 myVector; public bool Disabled() { return true; } public bool NotDisabled => false; } ``` ```csharp public class NaughtyComponent : MonoBehaviour { public bool flag0; public bool flag1; [DisableIf(EConditionOperator.And, "flag0", "flag1")] public int disabledIfAll; [DisableIf(EConditionOperator.Or, "flag0", "flag1")] public int disabledIfAny; } ``` -------------------------------- ### ValidateInput Attribute for Custom Validation Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Implement custom validation logic for fields using the ValidateInput attribute. This attribute can reference a method that returns a boolean and optionally display a custom error message. ```csharp public class _NaughtyComponent : MonoBehaviour { [ValidateInput("IsNotNull")] public Transform myTransform; [ValidateInput("IsGreaterThanZero", "myInteger must be greater than zero")] public int myInt; private bool IsNotNull(Transform tr) { return tr != null; } private bool IsGreaterThanZero(int value) { return value > 0; } } ``` -------------------------------- ### MinMaxSlider Attribute for Vector2 Range Selection Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The MinMaxSlider attribute creates a double slider for a Vector2 field, where the X property stores the minimum value and the Y property stores the maximum value within a specified range. ```csharp public class NaughtyComponent : MonoBehaviour { [MinMaxSlider(0.0f, 100.0f)] public Vector2 minMaxSlider; } ``` -------------------------------- ### ReorderableList Attribute for Array and List Reordering Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md The ReorderableList attribute provides an enhanced interface for array and List fields, allowing elements to be easily reordered directly within the inspector. ```csharp public class NaughtyComponent : MonoBehaviour { [ReorderableList] public int[] intArray; [ReorderableList] public List floatArray; } ``` -------------------------------- ### BoxGroup Attribute for Field Grouping Source: https://github.com/dbrizov/naughtyattributes/blob/master/README.md Use the [BoxGroup] attribute to visually group related fields within a box in the inspector. Fields with the same group name are placed together. ```csharp public class NaughtyComponent : MonoBehaviour { [BoxGroup("Integers")] public int firstInt; [BoxGroup("Integers")] public int secondInt; [BoxGroup("Floats")] public float firstFloat; [BoxGroup("Floats")] public float secondFloat; } ``` -------------------------------- ### Enforce Mandatory Reference Fields with Required Source: https://context7.com/dbrizov/naughtyattributes/llms.txt The Required attribute highlights reference fields with an error box if they are null, prompting the developer to assign them. An optional custom message can override the default error text. ```csharp using NaughtyAttributes; using UnityEngine; public class PlayerSetup : MonoBehaviour { [Required] public Camera mainCamera; [Required("The HUD canvas must be assigned before entering Play mode.")] public Canvas hudCanvas; [Required] public AudioSource audioSource; } ```