Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Attributes

Annulus Games edited this page Feb 12, 2023 · 3 revisions

Attributes

There are currently 31 types of attributes available.

General

ReadOnly

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [ReadOnly] public int foo;
    [ReadOnly] public int bar;
}

Button

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [Button]
    private void Foo()
    {
        Debug.Log("Foo!");
    }

    [Button(InspectorButtonSize.Large)]
    private void Bar()
    {
        Debug.Log("Bar!");
    }
}

PropertyOrder

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [PropertyOrder(1)] public int foo;
    [PropertyOrder(0)] public string bar;

    [PropertyOrder(-1), Button]
    private void Baz()
    {
        Debug.Log("Baz!");
    }
}

ShowInInspector

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [SerializeField]
    private int _foo;

    [ShowInInspector] 
    public int foo => _foo;

    [ShowInInspector]
    public int GetFoo()
    {
        return _foo;
    }
}

OnValueChanged

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [OnValueChanged("OnValueChanged")] public int foo;

    private void OnValueChanged(int value)
    {
        Debug.Log(value);
    }
}

HideMonoScript

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

[HideMonoScript]
public class AttributeExample : MonoBehaviour
{
    public int foo;
    public string bar;
}

DisableLucidEditor

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

[DisableLucidEditor]
public class AttributeExample : MonoBehaviour
{
    [SerializeReference] public IFoo foo;
    public string bar;
}

Decorations

Blockquote

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [Blockquote("Blockquote")]
    public int foo;
    public string bar;
}

TitleHeader

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [TitleHeader("Title")]
    public int foo;
    public string bar;
}

SectionHeader

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [SectionHeader("Section")]
    public int foo;
    public string bar;
}

HorizontalLine

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [HorizontalLine]
    public int foo;
    [HorizontalLine(InspectorColor.Red)]
    public string bar;
    [HorizontalLine(1f, 0.5f, 0f)]
    public Vector3 baz;
}

GUIColor

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [GUIColor(InspectorColor.EditorWarning)] public int foo;
    [GUIColor(0.5f, 0.5f, 0f)] public string bar;
}

Indent

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [Indent] public int foo;
    [Indent(2)] public string bar;
    [Indent(3)] public Vector3 baz;
}

HideLabel

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [HideLabel] public int foo;
    [HideLabel] public string bar;
}

LabelText

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [LabelText("Hello")] public int foo;
    [LabelText("World")] public string bar;
}

LabelWidth

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [LabelWidth(40f)] public int foo;
    [LabelWidth(200f)] public string bar;
}

HelpBox

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [HelpBox("Info")] public int foo;
    [HelpBox("Error", HelpBoxMessageType.Error)] public string bar;
}

HelpBoxIf

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [HelpBoxIf("IsNull", "obj is null.", HelpBoxMessageType.Error)] public GameObject obj;
    
    private bool IsNull()
    {
        return obj == null;
    }
}

Conditions

ShowIf

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    public bool show;
    [ShowIf("show")] public GameObject obj;

    [ShowIf("AlwaysTrue")] public int foo;
    [ShowIf("AlwaysFalse")] public string bar;

    private bool AlwaysTrue => true;
    private bool AlwaysFalse()
    {
        return false;
    }
}

HideIf

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    public bool hide;
    [HideIf("hide")] public GameObject obj;

    [HideIf("AlwaysTrue")] public int foo;
    [HideIf("AlwaysFalse")] public string bar;

    private bool AlwaysTrue => true;
    private bool AlwaysFalse()
    {
        return false;
    }
}

EnableIf

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    public bool active;
    [EnableIf("active")] public GameObject obj;

    [EnableIf("AlwaysTrue")] public int foo;
    [EnableIf("AlwaysFalse")] public string bar;

    private bool AlwaysTrue => true;
    private bool AlwaysFalse()
    {
        return false;
    }
}

DisableIf

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    public bool inactive;
    [DisableIf("inactive")] public GameObject obj;

    [DisableIf("AlwaysTrue")] public int foo;
    [DisableIf("AlwaysFalse")] public string bar;

    private bool AlwaysTrue => true;
    private bool AlwaysFalse()
    {
        return false;
    }
}

DisableInPlayMode

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [DisableInPlayMode] public int foo;
    [DisableInPlayMode] public string bar;
}

DisableInEditMode

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [DisableInEditMode] public int foo;
    [DisableInEditMode] public string bar;
}

Validation

Required

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [Required]
    public GameObject obj;
    
    [Required("Custom Message")]
    public Transform tr;
}

ValidateInput

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [ValidateInput("IsNotNull")]
    public GameObject obj;

    [ValidateInput("IsZeroOrGreater", "foo must be 0 or greater.")]
    public int foo = -1;

    private bool IsNotNull(GameObject go)
    {
        return go != null;
    }

    private bool IsZeroOrGreater(int a)
    {
        return a >= 0;
    }
}

Groups

Group

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [Group("GroupName")] public int foo;
    [Group("GroupName")] public string bar;
}

BoxGroup

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [BoxGroup("Box")] public int foo;
    [BoxGroup("Box")] public string bar;
}

FoldoutGroup

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [FoldoutGroup("Foldout")] public int foo;
    [FoldoutGroup("Foldout")] public string bar;
}

TabGroup

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [TabGroup("Tab", "Tab A")] public int foo;
    [TabGroup("Tab", "Tab B")] public string bar;
    [TabGroup("Tab", "Tab C")] public Vector3 baz;
}

HorizontalGroup

using UnityEngine;
using AnnulusGames.LucidTools.Inspector;

public class AttributeExample : MonoBehaviour
{
    [HorizontalGroup("Horizontal")] public int foo;
    [HorizontalGroup("Horizontal")] public int bar;
    [HorizontalGroup("Horizontal")] public int baz;
}