Class DropdownMenu
A drop-down menu.
Namespace: UnityEngine.UIElements
Syntax
public class DropdownMenu : object
Methods
AppendAction(String, Action<DropdownMenuAction>, Func<DropdownMenuAction, DropdownMenuAction.Status>, Object)
Add an item that will execute an action in the drop-down menu. The item is added at the end of the current item list.
Declaration
public void AppendAction(string actionName, Action<DropdownMenuAction> action, Func<DropdownMenuAction, DropdownMenuAction.Status> actionStatusCallback, object userData = null)
Parameters
Type | Name | Description |
---|---|---|
String | actionName | Name of the item. This name will be displayed in the drop-down menu. |
Action<DropdownMenuAction> | action | Callback to execute when the user selects this item in the menu. |
Func<DropdownMenuAction, DropdownMenuAction.Status> | actionStatusCallback | Callback to execute to determine the status of the item. |
Object | userData | An object that will be stored in the userData property of the DropdownMenuAction item. |
AppendAction(String, Action<DropdownMenuAction>, DropdownMenuAction.Status)
Add an item that will execute an action in the drop-down menu. The item is added at the end of the current item list.
Declaration
public void AppendAction(string actionName, Action<DropdownMenuAction> action, DropdownMenuAction.Status status = default(DropdownMenuAction.Status))
Parameters
Type | Name | Description |
---|---|---|
String | actionName | Name of the item. This name will be displayed in the drop-down menu. |
Action<DropdownMenuAction> | action | Callback to execute when the user selects this item in the menu. |
DropdownMenuAction.Status | status | The status of the item. |
AppendSeparator(String)
Add a separator line in the menu. The separator is added at the end of the current item list.
Declaration
public void AppendSeparator(string subMenuPath = null)
Parameters
Type | Name | Description |
---|---|---|
String | subMenuPath | The submenu path where the separator will be added. Path components are delimited by forward slashes ('/'). |
InsertAction(Int32, String, Action<DropdownMenuAction>, Func<DropdownMenuAction, DropdownMenuAction.Status>, Object)
Add an item that will execute an action in the drop-down menu. The item is added at the end of the specified index in the list.
Declaration
public void InsertAction(int atIndex, string actionName, Action<DropdownMenuAction> action, Func<DropdownMenuAction, DropdownMenuAction.Status> actionStatusCallback, object userData = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | atIndex | Index where the item should be inserted. |
String | actionName | Name of the item. This name will be displayed in the drop-down menu. |
Action<DropdownMenuAction> | action | Callback to execute when the user selects this item in the menu. |
Func<DropdownMenuAction, DropdownMenuAction.Status> | actionStatusCallback | Callback to execute to determine the status of the item. |
Object | userData | An object that will be stored in the userData property of the DropdownMenuAction item. This object is accessible through the action callback. |
InsertAction(Int32, String, Action<DropdownMenuAction>, DropdownMenuAction.Status)
Add an item that will execute an action in the drop-down menu. The item is added at the end of the specified index in the list.
Declaration
public void InsertAction(int atIndex, string actionName, Action<DropdownMenuAction> action, DropdownMenuAction.Status status = default(DropdownMenuAction.Status))
Parameters
Type | Name | Description |
---|---|---|
Int32 | atIndex | Index where the item should be inserted. |
String | actionName | Name of the item. This name will be displayed in the drop-down menu. |
Action<DropdownMenuAction> | action | Callback to execute when the user selects this item in the menu. |
DropdownMenuAction.Status | status | The status of the item. |
InsertSeparator(String, Int32)
Add a separator line in the menu. The separator is added at the end of the specified index in the list.
Declaration
public void InsertSeparator(string subMenuPath, int atIndex)
Parameters
Type | Name | Description |
---|---|---|
String | subMenuPath | The submenu path where the separator is added. Path components are delimited by forward slashes ('/'). |
Int32 | atIndex | Index where the separator should be inserted. |
MenuItems()
Get the list of menu items.
Declaration
public List<DropdownMenuItem> MenuItems()
Returns
Type | Description |
---|---|
List<DropdownMenuItem> | The list of items in the menu. |
PrepareForDisplay(EventBase)
Update the status of all items by calling their status callback and remove the separators in excess. This is called just before displaying the menu.
Declaration
public void PrepareForDisplay(EventBase e)
Parameters
Type | Name | Description |
---|---|---|
EventBase | e |
RemoveItemAt(Int32)
Remove the menu item at index.
Declaration
public void RemoveItemAt(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the item to remove. |