Home > database >  Unity editor: Is it possible to create easily editable shortcuts?
Unity editor: Is it possible to create easily editable shortcuts?

Time:04-27

I'm trying to create a custom editor script on Unity, and I'd like to have quite a few shortcuts for different reasons. Is there any way to create shortcuts that trigger an event in the Editor? Creating a custom editor just to edit the shortcuts of the first editor is impossible for me since I don't have that much time, but it would really help me to be able to change my own shortcuts easily.

As of now this is my code:

static void EditorGlobalKeyPress()
    {
        Event current = Event.current;
        if ((!current.alt && !current.control)|| current.type != EventType.KeyUp) return;
        switch (Event.current.keyCode)
        {
            case KeyCode.L:
                // Load stuff
                break;
            case KeyCode.U:
                // Unload stuff
                break;
            default:
                break;
        }
    }

And while it works fine, having editable shortcuts would be great. Does anyone know if it's possible in some way?

CodePudding user response:

Yes you can do this using a enter image description here

Also from a UX perspective this is better so a user can not only do this via the shortcut but also via the menu. And you can look up why things are happening when you press the shortcut buttons (see below) ;)


And then any user can still freely edit and reassign them later via the enter image description here

enter image description here

  • Related