Search Unity

Showing the Hierarchy > Create menu with EditorUtility.DisplayPopupMenu

Discussion in 'Immediate Mode GUI (IMGUI)' started by Keavon, Mar 13, 2015.

  1. Keavon

    Keavon

    Joined:
    Dec 13, 2010
    Posts:
    13
    I'm writing an editor extension and I want to add the ability to show the same menu that's shown when clicking Create in the Hierarchy window.



    I know that this is the same as what lies at the top of the GameObject menu. So I'm currently using

    Code (csharp):
    1. EditorUtility.DisplayPopupMenu(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0), "GameObject/", null);
    However, I don't want to show everything else after it. I am looking for how I can use just the subset that's shown in the Hierarchy window's Create dropdown.
     
  2. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    Here you go

    "Assets/Create"

    Code (CSharp):
    1.         EditorUtility.DisplayPopupMenu(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0), "Assets/Create", null);
     
    shahab-mos likes this.