Search Unity

Suggestion: Context Sensitive Keybinds

Discussion in 'Editor & General Support' started by xarismax, Jun 8, 2019.

  1. xarismax

    xarismax

    Joined:
    Jul 22, 2015
    Posts:
    11
    In Blender, the same keyboard shortcut is "listened" / "tracked" by multiple scripts. Each has its own condition.
    1. Example:
    a. Pressing "b" in 3d view => causes 3d object "box select"
    b. Pressing "b" in outliner or file list => creates a "draggable box to select 2d items".
    The difference between them is the "Condition" is:
    a. is mouse pointer inside "3d view"
    b. is mouse pointer inside "outliner" / "file viewer"

    In unity, in contrast, the same keyboard shortcut is allowed to be used by only one script. This causes conflicts.

    Unity allows to create keyboard shortcuts as follows:

    const string MenuTitle = "GameObject/Create Prefab From Selected %c";
    [MenuItem(MenuTitle)] static void CreatePrefab(){...} //blabla
    [MenuItem(MenuTitle, true)] static bool ValidateCreatePrefab()=>Selection.activeObject != null;

    This is a nice api, but you can go one step further.
    1. Evaluate all conditions by calling "all functions that share same keyboard command".
    2. if( one condition is true) then use it = no conflict. If many are true, then "conflict".

    Currently in my project, i am forced to disable unity shortcuts, because i want to use that button.

    Example: Evil probuilder is stealing my keyboard shortcuts and causes "conflicts".
    1. Probuilder could have as condition "if probuilder view mode toggle". +draw same widgets in screen to notify the viewer that he is in "probuilder" shortcuts mode.

    Conclusion: a de-centrelized system that doesn't cause conflicts in editor keybinds, If only one evaluates to true. This would allow more shortcuts from different developers without antagonizing the lack of remaining buttons.
     
  2. Flying_Banana

    Flying_Banana

    Joined:
    Jun 19, 2019
    Posts:
    29