Class Foldout
A Foldout control is a collapsible section of a user interface. When toggled, it expands or collapses, which hides or reveals the elements it contains.
Inherited Members
Namespace: UnityEngine.UIElements
Syntax
public class Foldout : BindableElement, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IBindable, INotifyValueChanged<bool>
Remarks
A Foldout consists of a Toggle sub-element and an empty VisualElement. The empty VisualElement is a container for the elements to show/hide when you expand/collapse the foldout. Foldout element's Toggle sub-element uses an arrow sprite instead of the Toggle control's usual checkbox. The arrow points right when the toggle is collapsed and down when it is expanded.
Constructors
Foldout()
Constructs a Foldout element.
Declaration
public Foldout()
Fields
contentUssClassName
The USS class name for the content element in a Foldout.
Declaration
public static readonly string contentUssClassName
Field Value
Type | Description |
---|---|
String |
Remarks
Unity adds this USS class to the VisualElement that contains the elements to be shown or hidden. Any styling applied to this class affects every foldout container located beside, or below the stylesheet in the visual tree.
toggleUssClassName
The USS class name of Toggle sub-elements in Foldout elements.
Declaration
public static readonly string toggleUssClassName
Field Value
Type | Description |
---|---|
String |
Remarks
Unity adds this USS class to the Toggle sub-element of every Foldout. Any styling applied to this class affects every Toggle sub-element located beside, or below the stylesheet in the visual tree.
ussClassName
The USS class name for Foldout elements.
Declaration
public static readonly string ussClassName
Field Value
Type | Description |
---|---|
String |
Remarks
Unity adds this USS class to every instance of a Foldout. Any styling applied to this class affects every Foldout located beside, or below the stylesheet in the visual tree.
Properties
contentContainer
This element contains the elements that are shown or hidden when you toggle the Foldout.
Declaration
public override VisualElement contentContainer { get; }
Property Value
Type | Description |
---|---|
VisualElement |
Overrides
text
This is the text of the toggle's label.
Declaration
public string text { get; set; }
Property Value
Type | Description |
---|---|
String |
value
This is the state of the Foldout's toggle. It is true if the Foldout is open and its contents are visible, and false if the Foldout is closed, and its contents are hidden.
Declaration
public bool value { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Methods
SetValueWithoutNotify(Boolean)
Sets the value of the Foldout's Toggle sub-element, but does not notify the rest of the hierarchy of the change.
Declaration
public void SetValueWithoutNotify(bool newValue)
Parameters
Type | Name | Description |
---|---|---|
Boolean | newValue | The new value of the foldout |
Implements
Remarks
This is useful when you want to change the Foldout's Toggle value without triggering events. For example, let's say you set up a Foldout to trigger an animation, but you only want to trigger the animation when a user clicks the Foldout's Toggle, not when you change the Toggle's value via code (for example, inside another validation). You could use this method change the value "silently". ///