Skip to content

Groups

Property group attributes used for grouping properties.

Info

Each property can have multiple different group attributes.

Demo

Let's create three field.

using UnityEngine;

public class ExampleComponent : MonoBehaviour
{
    public int health;
    public int minHealth;
    public int maxHealth;
}

Live-demo

Default fields view

Let’s add [Group] attribute to these three fields and name it Health Settings [Group("Health Settings")].

Note

Make sure that you have added ApexInspector namespace in your script, to get access to all attributes.

using ApexInspector;

using ApexInspector;
using UnityEngine;

public class ExampleComponent : MonoBehaviour
{
    [Group("Health Settings")]
    public int health;

    [Group("Health Settings")]
    public int minHealth;

    [Group("Health Settings")]
    public int maxHealth;
}

Live-demo

View after using [Group] attributes

You can combine differents group attributes. Let's add [Foldout] attribute to minHealth and maxHealth fields and name it Limits.

using ApexInspector;
using UnityEngine;

public class ExampleComponent : MonoBehaviour
{
    [Group("Health Settings")]
    public int health;

    [Group("Health Settings")] 
    [Foldout("Limits")]
    public int minHealth;

    [Group("Health Settings")] 
    [Foldout("Limits")]
    public int maxHealth;
}

Live-demo

View after combining [Group] and [Foldout] attributes

Let's set limits for minHealth and maxHealth fields by using [MinValue] and [MaxValue] validator attributes.

using ApexInspector;
using UnityEngine;

public class ExampleComponent : MonoBehaviour
{
    [Group("Health Settings")]
    [MinValue("minHealth")]
    [MaxValue("maxHealth")]
    public int health;

    [Group("Health Settings")] 
    [Foldout("Limits")]
    [MinValue(0)]
    [MaxValue("maxHealth")]
    public int minHealth;

    [Group("Health Settings")] 
    [Foldout("Limits")]
    [MinValue("minHealth")]
    [MaxValue(100)]
    public int maxHealth;
}

Live-demo

View after add [MinValue] and [MaxValue] validators