Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do I use Unity Shortcuts context classes?

Discussion in 'Editor & General Support' started by Ratslayer, Dec 5, 2019.

  1. Ratslayer

    Ratslayer

    Joined:
    Feb 6, 2014
    Posts:
    37
    I am trying to add new shortcuts using the shortcuts manager. The problem is that I want to bind them to WASD, without any additional qualifiers, which are already taken and thus results in conflicts. I want to add shortcuts for the axis selectors in the top left corner of Scene View. However, I want those shortcuts to only work when I am panning the view with my middle mouse button (then WASD keys would rotate the view).

    ShortcutAttribute takes "Type context" as its second parameter, but I can't find what type to use. The closest I found was UnityEditor.CameraFlyModeContext, which is the context for camera fly mode, but that class is internal and I can't access it.

    How would I go about creating those shortcuts?
     
  2. Rarceth

    Rarceth

    Joined:
    Oct 15, 2015
    Posts:
    41
  3. theforgot3n1

    theforgot3n1

    Joined:
    Sep 26, 2018
    Posts:
    188
    The issue here is that some build-in editor windows are not exposed. For example, it does not seem possible to find the Hierarchy window as a type, so you cant build a context shortcut for it... :(

    To answer OP directly though, SceneView is the name of the EditorWindow you want to provide as context into the shortcut attribute. Doing so will let the shortcut only trigger when the scene view window is active.