@@ -15,7 +15,28 @@ namespace UnityEditor
1515{
1616 public class SceneVisibilityManager : ScriptableSingleton < SceneVisibilityManager >
1717 {
18+ internal class ShortcutContext : IShortcutToolContext
19+ {
20+ public bool active
21+ {
22+ get
23+ {
24+ var focusedWindow = EditorWindow . focusedWindow ;
25+ if ( focusedWindow != null )
26+ {
27+ return ( focusedWindow . GetType ( ) == typeof ( SceneView ) ||
28+ focusedWindow . GetType ( ) == typeof ( SceneHierarchyWindow ) ) ;
29+ }
30+
31+ return false ;
32+ }
33+ }
34+ }
35+
36+ private static ShortcutContext s_ShortcutContext ;
37+
1838 public static event Action visibilityChanged ;
39+
1940 internal static event Action currentStageIsolated ;
2041
2142 private readonly static List < GameObject > m_RootBuffer = new List < GameObject > ( ) ;
@@ -41,6 +62,8 @@ private static void Initialize()
4162 SceneVisibilityState . internalStructureChanged += InternalStructureChanged ;
4263 PrefabStage stage = StageNavigationManager . instance . GetCurrentPrefabStage ( ) ;
4364 SceneVisibilityState . SetPrefabStageScene ( stage == null ? default ( Scene ) : stage . scene ) ;
65+ s_ShortcutContext = new ShortcutContext ( ) ;
66+ ShortcutIntegration . instance . contextManager . RegisterToolContext ( s_ShortcutContext ) ;
4467 }
4568
4669 private static void InternalStructureChanged ( )
@@ -322,8 +345,8 @@ public bool AreAllDescendantsVisible(GameObject gameObject)
322345 }
323346
324347 //SHORTCUTS
325- [ Shortcut ( "Scene Visibility/Toggle Selection Visibility" ) ]
326- static void ToggleSelectionVisibility ( )
348+ [ Shortcut ( "Scene Visibility/Toggle Visibility for Selection " ) ]
349+ private static void ToggleSelectionVisibility ( )
327350 {
328351 if ( Selection . gameObjects . Length > 0 )
329352 {
@@ -337,14 +360,14 @@ static void ToggleSelectionVisibility()
337360
338361 shouldHide = false ;
339362 }
340- Undo . RecordObject ( SceneVisibilityState . GetInstance ( ) , "Toggle Selection Visibility" ) ;
363+ Undo . RecordObject ( SceneVisibilityState . GetInstance ( ) , "Toggle Visibility for Selection " ) ;
341364 SceneVisibilityState . SetGameObjectsHidden ( Selection . gameObjects , shouldHide , false ) ;
342365 instance . VisibilityChanged ( ) ;
343366 }
344367 }
345368
346- [ Shortcut ( "Scene Visibility/Toggle Selection And Descendants Visibility" ) ]
347- static void ToggleSelectionAndDescendantsVisibility ( )
369+ [ Shortcut ( "Scene Visibility/Toggle Visibility for Selection and Children" , typeof ( ShortcutContext ) , KeyCode . H ) ]
370+ private static void ToggleSelectionAndDescendantsVisibility ( )
348371 {
349372 if ( Selection . gameObjects . Length > 0 )
350373 {
@@ -358,7 +381,7 @@ static void ToggleSelectionAndDescendantsVisibility()
358381
359382 shouldHide = false ;
360383 }
361- Undo . RecordObject ( SceneVisibilityState . GetInstance ( ) , "Toggle Visibility And Children" ) ;
384+ Undo . RecordObject ( SceneVisibilityState . GetInstance ( ) , "Toggle Visibility for Selection and Children" ) ;
362385 SceneVisibilityState . SetGameObjectsHidden ( Selection . gameObjects , shouldHide , true ) ;
363386 instance . VisibilityChanged ( ) ;
364387 }
@@ -425,20 +448,20 @@ private static void RevertIsolationCurrentStage()
425448 }
426449
427450 [ Shortcut ( "Scene Visibility/Exit Isolation" ) ]
428- static void ExitIsolationShortcut ( )
451+ private static void ExitIsolationShortcut ( )
429452 {
430453 instance . ExitIsolation ( ) ;
431454 }
432455
433- [ Shortcut ( "Scene Visibility/Toggle Selection And Descendants" ) ]
456+ [ Shortcut ( "Scene Visibility/Toggle Isolation for Selection and Children" , typeof ( ShortcutContext ) , KeyCode . H , ShortcutModifiers . Shift ) ]
434457 static void ToggleIsolateSelectionAndDescendantsShortcut ( )
435458 {
436459 instance . ToggleIsolateSelectionAndDescendants ( ) ;
437460 }
438461
439462 internal void ToggleIsolateSelectionAndDescendants ( )
440463 {
441- Undo . RecordObject ( SceneVisibilityState . GetInstance ( ) , "Toggle Isolation on Selection And Children" ) ;
464+ Undo . RecordObject ( SceneVisibilityState . GetInstance ( ) , "Toggle Isolation for Selection and Children" ) ;
442465
443466 if ( ! IsCurrentStageIsolated ( ) )
444467 {
@@ -459,15 +482,15 @@ internal void ToggleIsolateSelectionAndDescendants()
459482 }
460483 }
461484
462- [ Shortcut ( "Scene Visibility/Toggle Isolation on Selection" ) ]
485+ [ Shortcut ( "Scene Visibility/Toggle Isolation for Selection" ) ]
463486 static void ToggleIsolateSelectionShortcut ( )
464487 {
465488 instance . ToggleIsolateSelection ( ) ;
466489 }
467490
468491 internal void ToggleIsolateSelection ( )
469492 {
470- Undo . RecordObject ( SceneVisibilityState . GetInstance ( ) , "Toggle Isolation on Selection" ) ;
493+ Undo . RecordObject ( SceneVisibilityState . GetInstance ( ) , "Toggle Isolation for Selection" ) ;
471494
472495 if ( ! IsCurrentStageIsolated ( ) )
473496 {
0 commit comments