Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can you use the GameObject->UI->button to place [menuitems("tools/mine")] rather than code it all

Discussion in 'Immediate Mode GUI (IMGUI)' started by TheDodgerUk1, Sep 22, 2016.

  1. TheDodgerUk1

    TheDodgerUk1

    Joined:
    Dec 3, 2013
    Posts:
    61
    I have written a couple of tools which use the following kind of code

    Code (CSharp):
    1.     [MenuItem("Tools/Logging")]
    2.     static void Initialize()
    3.     {
    4.         m_Window = (Logging)EditorWindow.GetWindow(typeof(Logging), false, "Logging");
    5.     }
    6.    
    7.     void DrawInfo()
    8.     {
    9.        
    10.             EditorGUILayout.BeginHorizontal();
    11.             EditorGUILayout.LabelField("", GUILayout.Width(30));
    12.             EditorGUILayout.TextArea(lData.m_Data,GUILayout.Width(100));
    13.             EditorGUILayout.EndHorizontal();
    14.         }
    15.  
    Placing items via code is slow and pain full,
    there must be a better way , and if so , has anyone got a link were it shows it with a [MenuItem]
     
  2. MrMatthias

    MrMatthias

    Joined:
    Sep 18, 2012
    Posts:
    191
    no, but don't you want to execute code anyway?