@@ -22,25 +22,6 @@ internal enum WrapModeFixed
2222 PingPong = ( int ) WrapMode . PingPong
2323 }
2424
25- class AnimationShortcutContex : IShortcutToolContext
26- {
27- AnimEditor m_AnimEditor ;
28- public AnimationShortcutContex ( AnimEditor animEditor )
29- {
30- m_AnimEditor = animEditor ;
31- }
32-
33- public bool active
34- {
35- get { return ! animEditor . stateDisabled && ! animEditor . state . animatorIsOptimized ; }
36- }
37-
38- public AnimEditor animEditor
39- {
40- get { return m_AnimEditor ; }
41- }
42- }
43-
4425 internal class AnimEditor : ScriptableObject
4526 {
4627 // Active Animation windows
@@ -102,8 +83,6 @@ static private Color inRangeColor
10283 }
10384 }
10485
105- AnimationShortcutContex m_AnimationShortcutContex ;
106-
10786 internal const int kSliderThickness = 15 ;
10887 internal const int kLayoutRowHeight = EditorGUI . kWindowToolbarHeight + 1 ;
10988 internal const int kIntFieldWidth = 35 ;
@@ -356,9 +335,6 @@ public void OnEnable()
356335
357336 m_CurveEditor . curvesUpdated += SaveChangedCurvesFromCurveEditor ;
358337 m_CurveEditor . OnEnable ( ) ;
359-
360- m_AnimationShortcutContex = new AnimationShortcutContex ( this ) ;
361- ShortcutIntegration . instance . contextManager . RegisterToolContext ( m_AnimationShortcutContex ) ;
362338 }
363339
364340 public void OnDisable ( )
@@ -375,7 +351,6 @@ public void OnDisable()
375351 m_DopeSheet . OnDisable ( ) ;
376352
377353 m_State . OnDisable ( ) ;
378- ShortcutIntegration . instance . contextManager . DeregisterToolContext ( m_AnimationShortcutContex ) ;
379354 }
380355
381356 public void OnDestroy ( )
@@ -729,10 +704,13 @@ private void LinkOptionsOnGUI()
729704
730705 static void ExecuteShortcut ( ShortcutArguments args , Action < AnimEditor > exp )
731706 {
732- var animEditorContext = ( AnimationShortcutContex ) args . context ;
733- var animEditor = animEditorContext . animEditor ;
707+ var animationWindow = ( AnimationWindow ) args . context ;
708+ var animEditor = animationWindow . animEditor ;
709+
710+ if ( EditorWindow . focusedWindow != animationWindow )
711+ return ;
734712
735- if ( EditorWindow . focusedWindow != animEditor . m_OwnerWindow )
713+ if ( animEditor . stateDisabled || animEditor . state . animatorIsOptimized )
736714 return ;
737715
738716 exp ( animEditor ) ;
@@ -746,14 +724,14 @@ static void ExecuteShortcut(ShortcutArguments args, Action<IAnimationWindowContr
746724 }
747725
748726 [ FormerlyPrefKeyAs ( "Animation/Show Curves" , "c" ) ]
749- [ Shortcut ( "Animation/Show Curves" , typeof ( AnimationShortcutContex ) , "c" ) ]
727+ [ Shortcut ( "Animation/Show Curves" , typeof ( AnimationWindow ) , "c" ) ]
750728 static void ShowCurves ( ShortcutArguments args )
751729 {
752730 ExecuteShortcut ( args , animEditor => { animEditor . SwitchBetweenCurvesAndDopesheet ( ) ; } ) ;
753731 }
754732
755733 [ FormerlyPrefKeyAs ( "Animation/Play Animation" , " " ) ]
756- [ Shortcut ( "Animation/Play Animation" , typeof ( AnimationShortcutContex ) , " " ) ]
734+ [ Shortcut ( "Animation/Play Animation" , typeof ( AnimationWindow ) , " " ) ]
757735 static void TogglePlayAnimation ( ShortcutArguments args )
758736 {
759737 ExecuteShortcut ( args , controlInterface =>
@@ -766,76 +744,75 @@ static void TogglePlayAnimation(ShortcutArguments args)
766744 }
767745
768746 [ FormerlyPrefKeyAs ( "Animation/Next Frame" , "." ) ]
769- [ Shortcut ( "Animation/Next Frame" , typeof ( AnimationShortcutContex ) , "." ) ]
747+ [ Shortcut ( "Animation/Next Frame" , typeof ( AnimationWindow ) , "." ) ]
770748 static void NextFrame ( ShortcutArguments args )
771749 {
772750 ExecuteShortcut ( args , controlInterface => controlInterface . GoToNextFrame ( ) ) ;
773751 }
774752
775753 [ FormerlyPrefKeyAs ( "Animation/Previous Frame" , "," ) ]
776- [ Shortcut ( "Animation/Previous Frame" , typeof ( AnimationShortcutContex ) , "," ) ]
754+ [ Shortcut ( "Animation/Previous Frame" , typeof ( AnimationWindow ) , "," ) ]
777755 static void PreviousFrame ( ShortcutArguments args )
778756 {
779757 ExecuteShortcut ( args , controlInterface => controlInterface . GoToPreviousFrame ( ) ) ;
780758 }
781759
782760 [ FormerlyPrefKeyAs ( "Animation/Previous Keyframe" , "&," ) ]
783- [ Shortcut ( "Animation/Previous Keyframe" , typeof ( AnimationShortcutContex ) , "&," ) ]
761+ [ Shortcut ( "Animation/Previous Keyframe" , typeof ( AnimationWindow ) , "&," ) ]
784762 static void PreviousKeyFrame ( ShortcutArguments args )
785763 {
786764 ExecuteShortcut ( args , controlInterface => controlInterface . GoToPreviousKeyframe ( ) ) ;
787765 }
788766
789767 [ FormerlyPrefKeyAs ( "Animation/Next Keyframe" , "&." ) ]
790- [ Shortcut ( "Animation/Next Keyframe" , typeof ( AnimationShortcutContex ) , "&." ) ]
768+ [ Shortcut ( "Animation/Next Keyframe" , typeof ( AnimationWindow ) , "&." ) ]
791769 static void NextKeyFrame ( ShortcutArguments args )
792770 {
793771 ExecuteShortcut ( args , controlInterface => controlInterface . GoToNextKeyframe ( ) ) ;
794772 }
795773
796774 [ FormerlyPrefKeyAs ( "Animation/First Keyframe" , "#," ) ]
797- [ Shortcut ( "Animation/First Keyframe" , typeof ( AnimationShortcutContex ) , "#," ) ]
775+ [ Shortcut ( "Animation/First Keyframe" , typeof ( AnimationWindow ) , "#," ) ]
798776 static void FirstKeyFrame ( ShortcutArguments args )
799777 {
800778 ExecuteShortcut ( args , controlInterface => controlInterface . GoToFirstKeyframe ( ) ) ;
801779 }
802780
803781 [ FormerlyPrefKeyAs ( "Animation/Last Keyframe" , "#." ) ]
804- [ Shortcut ( "Animation/Last Keyframe" , typeof ( AnimationShortcutContex ) , "#." ) ]
782+ [ Shortcut ( "Animation/Last Keyframe" , typeof ( AnimationWindow ) , "#." ) ]
805783 static void LastKeyFrame ( ShortcutArguments args )
806784 {
807785 ExecuteShortcut ( args , controlInterface => controlInterface . GoToLastKeyframe ( ) ) ;
808786 }
809787
810788 [ FormerlyPrefKeyAs ( "Animation/Key Selected" , "k" ) ]
811- [ Shortcut ( "Animation/Key Selected" , typeof ( AnimationShortcutContex ) , "k" ) ]
789+ [ Shortcut ( "Animation/Key Selected" , null , "k" ) ]
812790 static void KeySelected ( ShortcutArguments args )
813791 {
814- var animEditorContext = ( AnimationShortcutContex ) args . context ;
815- var animEditor = animEditorContext . animEditor ;
816-
817- if ( ! animEditor . m_State . previewing )
792+ AnimationWindow animationWindow = AnimationWindow . GetAllAnimationWindows ( ) . Find ( aw => ( aw . state . previewing || aw == EditorWindow . focusedWindow ) ) ;
793+ if ( animationWindow == null )
818794 return ;
819795
796+ var animEditor = animationWindow . animEditor ;
797+
820798 animEditor . SaveCurveEditorKeySelection ( ) ;
821799 AnimationWindowUtility . AddSelectedKeyframes ( animEditor . m_State , animEditor . controlInterface . time ) ;
822- if ( ! animEditor . m_OwnerWindow . hasFocus )
823- animEditor . controlInterface . ClearCandidates ( ) ;
800+ animEditor . controlInterface . ClearCandidates ( ) ;
824801 animEditor . UpdateSelectedKeysToCurveEditor ( ) ;
825802
826803 animEditor . Repaint ( ) ;
827804 }
828805
829806 [ FormerlyPrefKeyAs ( "Animation/Key Modified" , "#k" ) ]
830- [ Shortcut ( "Animation/Key Modified" , typeof ( AnimationShortcutContex ) , "#k" ) ]
807+ [ Shortcut ( "Animation/Key Modified" , null , "#k" ) ]
831808 static void KeyModified ( ShortcutArguments args )
832809 {
833- var animEditorContext = ( AnimationShortcutContex ) args . context ;
834- var animEditor = animEditorContext . animEditor ;
835-
836- if ( ! animEditor . m_State . previewing )
810+ AnimationWindow animationWindow = AnimationWindow . GetAllAnimationWindows ( ) . Find ( aw => ( aw . state . previewing || aw == EditorWindow . focusedWindow ) ) ;
811+ if ( animationWindow == null )
837812 return ;
838813
814+ var animEditor = animationWindow . animEditor ;
815+
839816 animEditor . SaveCurveEditorKeySelection ( ) ;
840817 animEditor . controlInterface . ProcessCandidates ( ) ;
841818 animEditor . UpdateSelectedKeysToCurveEditor ( ) ;
@@ -1226,6 +1203,7 @@ private void InitializeCurveEditor()
12261203 settings . allowDeleteLastKeyInCurve = true ;
12271204 settings . rectangleToolFlags = CurveEditorSettings . RectangleToolFlags . FullRectangleTool ;
12281205 settings . undoRedoSelection = true ;
1206+ settings . flushCurveCache = false ; // Curve Wrappers are cached in AnimationWindowState.
12291207
12301208 m_CurveEditor . shownArea = new Rect ( 1 , 1 , 1 , 1 ) ;
12311209 m_CurveEditor . settings = settings ;
0 commit comments