Search Unity

Feedback Request: Allow user to move MenuItems and CreateAssetMenus

Discussion in 'General Discussion' started by joshcamas, Dec 4, 2022.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    This issue is twofold:
    - Unity's own menu items can be inconsistent, and the create asset menu's are particularly egregious. Luckily the Windows menu is super organized nowadays, which is great, but the Create menu is terrifying, and just having the default unity installation with a few unity packages will result in a menu larger than my screen.
    - Addons are inconsistent where they put their menu items in particular. Luckily a good number have put their stuff under the Tools menu (THANK YOU!!!!), but others put their stuff under the Windows menu, which makes things really cluttered.

    At this point, I don't think Unity will ever clean up the create asset menus. And it's essentially impossible to assume all unity addon creators will be consistent either.

    THUS my proposed solution: allow us to organize our own projects! Having a tool that lets us remap menu items would be very useful, and solve this issue by putting the solving part in our hands.

    Wildcard Example:
    Cinemachine/* -> Tools/Cinemachine/*

    Specific Item Example
    Create/Animation -> Create/Animations/Animation
    Create/Animator Controller -> Create/Animations/Animator Controller
    Create/Animator Override Controller -> Create/Animations/Animator Override Controller

    This is the same direction as the editor shortcut tool, and is very useful in my opinion. Giving the ability to easily share our remappings would be nice as well, then we can share our cleanups with everyone else :)
     
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,145
    This has been a long desired feature of mine. It doesn't even take external packages for the create menu to become unmanageable. As you said, it's easy for the menu to become larger than the screen with standard package manager packages.
     
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,157
    I'm a little surprised I haven't seen someone make an asset for this.

    upload_2022-12-4_18-43-40.png

    Code (csharp):
    1. using System.Reflection;
    2. using UnityEditor;
    3.  
    4. class MyEditorScript
    5. {
    6.     [InitializeOnLoadMethod]
    7.     static void Initialize()
    8.     {
    9.         RemoveMenuItem("GameObject");
    10.         RemoveMenuItem("GameObject/Create Empty");
    11.         AddMenuItem("GameObject/Create Empty", CreateEmpty);
    12.     }
    13.  
    14.     static void AddMenuItem(string menuItem, System.Action execute)
    15.     {
    16.         typeof(Menu).GetMethod("AddMenuItem", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, new object[] { menuItem, null, null, -1, execute, null });
    17.     }
    18.  
    19.     static void RemoveMenuItem(string menuItem)
    20.     {
    21.         typeof(Menu).GetMethod("RemoveMenuItem", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, new object[] { menuItem });
    22.     }
    23.  
    24.     static void CreateEmpty()
    25.     {
    26.         // Code
    27.     }
    28. }
     
  4. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    OH hell yeah! Looks like there is a GetMenuItems method as well, which could be used for wildcarding. Time to look into this :)

    EDIT: And... nope. Doesn't seem to have a way to get a menu item's action, and thus can't really automatically remap. :( TECHNICALLY I could have the tool scan all the assemblies for a matched MenuItem attribute, and then save the path to run the same method again... but that's more annoying. It does look like Unity uses the TypeCache for menu items, which suggests that all Menu items are guaranteed to be in the TypeCache, which does make it possible though....
     
    Last edited: Dec 5, 2022
  5. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    Well, I got it partially working. Made a tool that can remap whatever menu items I could find via TypeCache.

    However there are a lot of missing built in unity creation menus (Animation, Scene, etc). One rather silly option could be to add these manually. Note the issue is I can cannot get the associated Action that is triggered when a menu is clicked for these items.



    Still a good step forward though. Doesn't support wildcard yet nor reordering.
     
    MadeFromPolygons likes this.
  6. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    I really like this idea. The further along a project gets the more a team knows about what they do and don't use, so being able to configure our own layouts makes a lot of sense, even if everything that was originally there makes perfect sense in a general case.

    And I'd really like to be able to hide built-in functionality in those cases where a replacement is being used.

    - - -

    Actually, I don't know about now, but there used to be at least some rules around this as a part of the asset submission guidelines, which got ignored / flaunted / overlooked / whatever. They could be enforced, possibly including Unity warning everyone of an upcoming review and threatening deprecation for assets misbehaving.
     
    joshcamas likes this.