Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

IShortcutToolContext -- Can I use it, pretty please??

Discussion in 'UIElements' started by awesomedata, Jul 28, 2019.

  1. awesomedata


    Oct 8, 2014
    As explained, I really want to use IShortcutToolContext in my shortcuts (for continuous interactive scene control via my own (user-reassignable) shortcuts.)

    This interface is used in the flythrough mode in the scene camera controller. I want to use it in other tools.

    In 2019.1, it's currently not possible to add any truly interactive scene controls (using the new ShortcutManagement system) without this -- all because this interface was deemed "internal" only for some reason.

    There are SO MANY great tools that can be made by users like me with access to this interface (such as completely custom scene camera controllers!) -- And it would bring money to Unity on the Asset Store too, so it's win-win.
    So why am I not allowed to implement my own camera orbit behavior -- or even my own gradual color tweak tool for modifying a gameobject's color while holding a key for R, G, or B?
    These are simple tool ideas, but much better stuff could be made if people had access to this when designing their games!!

    Lots of cool tools will never be possible with the new shortcut management system policing our access to things like this. So please open this context up (and add more!) so you can democratize this type of stuff too, @Unity!
  2. leo-carneiro


    Unity Technologies

    Sep 1, 2011

    Glad to hear that you are looking into using the new Shortcut Manager APIs.

    We were expecting that with the APIs we have exposed so far, it would indeed be possible to build interactive scene controls by using the SceneView as the ShortcutContext.

    Can you expand a bit more on what exactly are you trying to achieve that you are not able to do with current public API?

    Lars-Steenhoff likes this.
  3. awesomedata


    Oct 8, 2014
    I, for example, have an asset that lets me drive the scene camera however I wish in older Unity versions. I had to do some hacks to get this working, but it worked pretty decently. I had my own orbit and zoom that worked way better than Unity's default scene camera controller. However, moving the scene camera in real-time using the new shortcut management system in 2019.x is impossible due to having to jump through hoops to define a proper tool when I simply want a key to respond and execute a script until I tell it to stop by letting go of the key.

    In tool examples like the RGB shifting in real-time, I don't necessarily want this to be tied to an editor window. In the case of a scene camera, I don't necessarily want this to be tied to a particular editor window. For example, maybe I want to hold control and switch to an entirely different method of navigating my scene -- i.e. I might only want my orthographic scene camera to shift by exactly 1 screen at a time with a slight delay as long as I am holding the control key and holding my arrow keys.

    That same example could apply to moving the selected gameobject along a grid, with a scene raycast to determine the height of the next grid cell before shifting it, with this method being repeated as long as an arrow key is being pressed in the editor. This is nothing but a quality of life improvement tool for navigating a scene for a particular game style, but it can make life amazing for the person using it for a grid-based game.

    By no means is this limited to scene camera/gameobject tools though. The ability to play a physics simulation while holding a key and stopping at just the right moment upon releasing it could be another good use of realtime editor shortcuts. Doing this with a button or a dedicated tool simply wouldn't allow the sort of fine control one might need for lots of iterations through groups of gameobjects when decorating a scene with lots of physically placed objects via simulations. There are just some occasions in the editor when you simply need a constant keyboard press to execute a static method until the editor realizes you've stopped pressing it.

    Thus far, I've only mentioned the scene view, but there are also times when I want to essentially program the equivalent of a macro too. For example, I might want to press and hold a single key to temporarily display an editor window (i.e the Game View) and then hide it when I release the key. I actually do this with Snapcam's windows, which proved to be problematic when trying to use a pop-up window that should have also been dockable (the Grid Navigator), but broke Unity when trying to do that particular thing. The problem was, some customers of mine liked it as a quick popup, but others liked it docked. Some wanted to be able to do both with the same physical window. I had to do some fancy reflection magic just to hide and show my suite of windows via shortcuts that could be accessed globally in previous versions of Unity, so I was excited to see a proper shortcut system in the works. However, I can't be tied down to the scene view as my context because all of my tools -- and their editor windows -- were designed to get the heck out of your way when you no longer needed them. This means an invisible editor window that handles logic like shortcuts. This design is impossible using the scene view context alone, since some of my tools I've planned have nothing to do with the scene view and act as their own sort of management systems that work across multiple window contexts. What if the user closes the scene view window? Ultimately, it's too hacky to do things as I did pre-2019. I can currently not make these according to my design without the system being unwieldy again.

    IShortcutToolContext seems like it would be a great fit for game-specific quality of life tools as much as it would be a great fit for tools that modify the editor UI itself, such as me wanting to override the sleek new editor camera controller to make a version that orbits and moves exactly how _I_ want it to for editing _my_ specific game.

    To put such essential UX stuff out of the hands of advanced users capable of understanding and controlling it should be a crime in my personal opinion. Unity has been too unwieldy for much too long for this to still be okay with you guys. :(

    Please at least let us use or at least override stuff like the above-mentioned user-experience elements (such as this interface or the scene camera controller.) This would be so much appreciated by so many people.
  4. awesomedata


    Oct 8, 2014
    So how might one use the SceneView as the ShortcutContext? -- As far as I'm aware, there's no way to use it as the context.

    Also, when I use something like:

    Code (CSharp):
    1. [Shortcut("MoveMode", null, KeyCode.A)]
    2.     static void MoveView ()
    3.     {
    4. //etc.
    5. }
    This executes only at the repeat rate of the keyboard.

    This is a problem. It doesn't repeat instantly (like using WASD in Flymode while holding RMB). I need the fluidity like that in my shortcut. In addition to this, overriding Mouse button behaviors in the scene context would be incredibly useful when you want to perform a different function than what the SceneView's SimpleCameraController enables. The "KeyCode.Mouse1" and others don't seem to work (and throw errors) in 2019.2 with using a null context. This might have something to do with the null context itself though, so being able to use mouse shortcuts in the scene view would be nice.

    Much of this I want to use to develop innovative tools and interfaces for UX purposes, but I can't do this without _at least_ this level of control.

    Being able to modify the current SceneView camera controller by overriding parts of it would be a first step (maybe make it a package??), but it wouldn't be general enough for some editor tools I want to make...