EditorUtility.DisplayPopupMenu 显示弹出菜单

static function DisplayPopupMenu (position : Rect, menuItemPath : string, command : MenuCommand) : void

Description描述

Displays a popup menu.

显示一个弹出菜单。

Menu is shown at position pos, generated from a submenu specified by menuItemPath using a MenuCommand as menu context.

菜单显示在position位置,从menuItemPath指定的子菜单生成,使用MenuCommand作为菜单上下文。

// Shows the Assets menu when you right click on the contextRect Rectangle.
//当右击contextRect矩形,显示资源菜单
class EditorUtilityDisplayPopupMenu extends EditorWindow {
	function OnGUI () {
		var evt = Event.current;
		var contextRect = Rect(10,10,100,100);
		if(evt.type == EventType.ContextClick) {
			var mousePos = evt.mousePosition;
			if (contextRect.Contains (mousePos)) {
				EditorUtility.DisplayPopupMenu (Rect (mousePos.x,mousePos.y,0,0), "Assets/", null);
				evt.Use();
			}
		}
	}
}
Page last updated: 2011-7-15