Legacy Documentation: Version 2017.2 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorUtility.DisplayPopupMenu

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static method DisplayPopupMenu(position: Rect, menuItemPath: string, command: MenuCommand): void;
public static void DisplayPopupMenu(Rect position, string menuItemPath, MenuCommand command);

Description

Displays a popup menu.

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

#pragma strict
// Shows the Assets menu when you right click on the contextRect Rectangle.
public class EditorUtilityDisplayPopupMenu extends MonoBehaviour {
	function OnGUI() {
		var evt: Event = Event.current;
		var contextRect: Rect = new Rect(10, 10, 100, 100);
		if (evt.type == EventType.ContextClick) {
			var mousePos: Vector2 = evt.mousePosition;
			if (contextRect.Contains(mousePos)) {
				EditorUtility.DisplayPopupMenu(new Rect(mousePos.x, mousePos.y, 0, 0), "Assets/", null);
				evt.Use();
			}
		}
	}
}
using UnityEditor;
using UnityEngine;
using System.Collections;

// Shows the Assets menu when you right click on the contextRect Rectangle. public class EditorUtilityDisplayPopupMenu : MonoBehaviour { void OnGUI() { Event evt = Event.current; Rect contextRect = new Rect(10, 10, 100, 100); if (evt.type == EventType.ContextClick) { Vector2 mousePos = evt.mousePosition; if (contextRect.Contains(mousePos)) { EditorUtility.DisplayPopupMenu(new Rect(mousePos.x, mousePos.y, 0, 0), "Assets/", null); evt.Use(); } } } }

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