语言English
  • C#

EditorToolContext.PopulateMenu

声明

public void PopulateMenu(UIElements.DropdownMenu menu);

参数

menu 要向其中添加菜单项的场景视图上下文菜单。

描述

向场景视图上下文菜单添加菜单项。

请参阅 MenuUtility,了解用于向场景视图上下文菜单添加菜单项的实用程序函数。

public override void PopulateMenu(DropdownMenu menu)
{
    // Add all clipboard operations to the context menu (Cut, Copy, Paste, Delete, and Duplicate).
    ContextMenuUtility.AddClipboardEntriesTo(menu);

    // Add an item to the context menu using a delegate or an EditorAction.
    menu.AppendAction("Parent Item/Child Item", (item) => Debug.Log("Executed Child Item."));

    // Add an item to the context menu using a predefined MenuItem.
    ContextMenuUtility.AddMenuItem(menu, "GameObject/Move To View");
}

Did you find this page useful? Please give it a rating: