DropDown
Displays the menu at the specified position.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
DropDown(Rect, VisualElement, bool)
Displays the menu at the specified position.
public void DropDown(Rect position, VisualElement targetElement = null, bool anchored = false)
Parameters
The position in the coordinate space of the panel.
The element determines which root to use as the menu's parent.
If true, the menu's width matches the width of the ; otherwise, the menu expands to the container's full width.
positionRemarks
The parent element that displays the menu:
- For Editor UI, the parent element is EditorWindow.rootVisualElement.
- For runtime UI, the parent element is UIDocument.rootVisualElement.
The parameter determines the width of the menu. Refer to GenericDropdownMenu for example usages.
anchoredDropDown(Rect, VisualElement, bool, bool)
Displays the menu at the specified position.
public void DropDown(Rect position, VisualElement targetElement = null, bool anchored = false, bool fitContentWidthIfAnchored = false)
Parameters
The position in the coordinate space of the panel.
The element determines which root to use as the menu's parent.
If true, the menu's width matches the width of the ; otherwise, the menu expands to the container's full width.
positionIf true and the menu is anchored, the menu's width matches its content's width; otherwise, the menu's width matches the width of the . If the menu is unanchored, this parameter is ignored.
positionRemarks
The parent element that displays the menu:
- For Editor UI, the parent element is EditorWindow.rootVisualElement.
- For runtime UI, the parent element is UIDocument.rootVisualElement.
The and parameters determine the width of the menu. Refer to GenericDropdownMenu for example usages.
anchoredfitContentWidthIfAnchored