GroupBox
UnityEngine.UIElements.GroupBox
読み終わるまでの所要時間 1 分最終更新 23日前
A GroupBox is a container element for a logical group of multiple buttons (including radio buttons) or toggles. You can use a combination of GroupBox and RadioButton if you want to have multiple groups of options in the same panel.

Two group boxes with three radio buttons each.
If you want to treat your group of radio buttons as a single field, use RadioButtonGroup. In most cases, it's better to use RadioButtonGroup because you must register every single radio button when you use the GroupBox and RadioButton combo. However, use the combo if you want to add additional visual elements in the group.

A group box with two radio buttons, an input text field, and a button.
Create a GroupBox with C# script
The following C# code snippets create a GroupBox and add three radio buttons to it so that they're logically grouped.
var group = new GroupBox("Group Example");// Must register change events on each radio button.var choice1 = new RadioButton("First Choice");choice1.RegisterValueChangedCallback(v => Debug.Log("Choice 1 is : " + v.newValue));var choice2 = new RadioButton("Second Choice");choice2.RegisterValueChangedCallback(v => Debug.Log("Choice 2 is : " + v.newValue));var choice3 = new RadioButton("Third Choice");choice3.RegisterValueChangedCallback(v => Debug.Log("Choice 3 is : " + v.newValue));group.Add(choice1);group.Add(choice2);group.Add(choice3);rootVisualElement.Add(group);
C# class and namespace
C# class:
GroupBoxNamespace:
UnityEngine.UIElementsBase class:
BindableElementMember UXML attributes
This element has the following member attributes:
Name | Type | Description |
|---|---|---|
| | The title text of the box. |
Inherited UXML attributes
This element inherits the following attributes from its base class:
Name | Type | Description |
|---|---|---|
| | Path of the target property to be bound. |
| | Whether an element can potentially receive focus. If false, the element can't receive focus. If true, the element receives focus only when its |
| | An integer used to sort focusable elements in the focus ring. Must be greater than or equal to zero. Setting the |
This element also inherits the following attributes from :
VisualElementName | Type | Description |
|---|---|---|
| | Logical container where child elements are added. If a child is added to this element, the child is added to this element's content container instead. When iterating over the If the content container is the same as the element itself, child elements are added directly to the element. This is true for most elements but can be overridden by more complex types. The |
| | Assigns a data source to this VisualElement which overrides any inherited data source. This data source is inherited by all children. |
| | Path from the data source to the value. |
| | The possible type of data source assignable to this VisualElement. This information is only used by the UI Builder as a hint to provide some completion to the data source path field when the effective data source cannot be specified at design time. |
| | Returns true if the This flag isn't changed if the VisualElement is disabled implicitly by one of its parents. To verify this, use |
| | Indicates the directionality of the element's text. The value will propagate to the element's children. |
| | The name of this VisualElement. Use this property to write USS selectors that target a specific element. The standard practice is to give an element a unique name. |
| | Determines if this element can be the target of pointer events or picked by Elements can not be picked if: - They are invisible- Their Elements with a picking mode of |
| | Sets the style values on a The returned style data, computed from USS files or inline styles written to this object in C#, doesn't represent the fully resolved styles, such as the final height and width of a VisualElement. To access these fully resolved styles, use For information about how to use this property and all the supported USS properties, refer to the Apply styles in C# scripts and USS properties reference manual pages. |
| | Text to display inside an information box after the user hovers the element for a small amount of time. This is only supported in the Editor UI. |
| | A combination of hint values that specify high-level intended usage patterns for the |
| | Used for view data persistence, such as tree expanded states, scroll position, or zoom level. This key is used to save and load the view data from the view data store. If you don't set this key, the persistence is disabled for the associated |
USS classes
The following table lists all the C# public property names and their related USS selector.
C# property | USS selector | Description |
|---|---|---|
| | USS class name for GroupBox elements. Unity adds this USS class to every instance of the GroupBox element. Any styling applied to this class affects every GroupBox located beside, or below the stylesheet in the visual tree. |
| | USS class name for Labels in GroupBox elements. Unity adds this USS class to the |
| | USS class name of local disabled elements. |
You can also use the Matching Selectors section in the Inspector or the UI Toolkit Debugger to see which USS selectors affect the components of the at every level of its hierarchy.
VisualElement