Class FoldoutAttribute
Groups serialized fields under a collapsible foldout section in the Unity Inspector.
Inherited Members
Namespace: Scylla.Core.Attributes
Assembly: ScyllaCore.dll
Syntax
[AttributeUsage(AttributeTargets.Field)]
public sealed class FoldoutAttribute : PropertyAttribute
Remarks
Applying this attribute to multiple fields with the same GroupName causes them to be grouped together under a single collapsible foldout header. Fields without this attribute are drawn outside any foldout group, in the order they appear in the class.
Hierarchical nesting is supported by using the "/" delimiter in the group name
(e.g., "Combat/Offense"). This creates a nested foldout structure where
"Offense" appears as a child group inside "Combat".
The collapsed or expanded state of each foldout is persisted per object instance for the duration of the current Editor session. The DefaultExpanded property controls the initial state of a foldout the first time it is encountered.
Use TitleAttribute instead when a purely decorative section header is needed without collapsible grouping behavior.
public class Character : MonoBehaviour
{
/* Both fields share the same "Movement" foldout */
[Foldout("Movement")]
[SerializeField] private float _moveSpeed = 5f;
[Foldout("Movement")]
[SerializeField] private float _jumpHeight = 2f;
/* Hierarchical nesting using "/" delimiter */
[Foldout("Combat/Offense")]
[SerializeField] private float _attackDamage = 10f;
/* Start collapsed by default */
[Foldout("Combat/Defense", DefaultExpanded = false)]
[SerializeField] private float _armor = 5f;
}
Constructors
FoldoutAttribute(string)
Creates a new foldout group with the specified group name. The foldout will start expanded by default.
Declaration
public FoldoutAttribute(string groupName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | groupName | The display name of the foldout group. Fields sharing this exact name (case-
sensitive) will be grouped together. Use "/" to create nested foldouts
(e.g., |
Remarks
Fields with the same groupName value on the same object
are automatically collected under a single foldout header in the Inspector.
The foldout expands on first display unless DefaultExpanded
is set to false after construction.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Properties
DefaultExpanded
Gets or sets whether the foldout starts in the expanded state the first time it is encountered in the Inspector.
Declaration
public bool DefaultExpanded { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Remarks
Defaults to true, which means the foldout is open by default. Set to
false to start collapsed, which is useful for large groups of rarely-
edited fields. Once the user manually expands or collapses the foldout, the
user's preference is retained for the duration of the Editor session.
GroupName
Gets the display name of the foldout group.
Declaration
public string GroupName { get; }
Property Value
| Type | Description |
|---|---|
| string | A non-null, non-empty string identifying the foldout group. Set once at construction and immutable thereafter. |
Remarks
All fields decorated with a FoldoutAttribute sharing this same
group name on the same serialized object are rendered inside a single foldout.
Use "/" as a delimiter to create hierarchical (nested) foldouts
(e.g., "Graphics/Shadows" creates a "Shadows" group nested inside
"Graphics").