private void OnUpdate() { if (!_syncWithAnimationWindow) { return; } if (Selection.activeTransform != Track.Owner) { Selection.activeTransform = Track.Owner; } if (!AnimationMode.InAnimationMode()) { // AnimationMode.StartAnimationMode(); AnimationWindowProxy.StartAnimationMode(); } // if( _track.IsPreviewing ) { int animWindowFrame = AnimationWindowProxy.GetCurrentFrame(); FEvent[] evts = new FEvent[2]; int numEvts = Track.GetEventsAt(SequenceEditor.Sequence.CurrentFrame, ref evts); if (numEvts > 0) { FPlayAnimationEvent animEvt = (FPlayAnimationEvent)evts[numEvts - 1]; if (animEvt.ControlsAnimation) { int normCurrentFrame = SequenceEditor.Sequence.CurrentFrame - animEvt.Start; if (animWindowFrame > animEvt.Length) { animWindowFrame = animEvt.Length; AnimationWindowProxy.SetCurrentFrame(animWindowFrame, animEvt.LengthTime); } if (animWindowFrame >= 0 && animWindowFrame != normCurrentFrame) { SequenceEditor.SetCurrentFrame(animEvt.Start + animWindowFrame); SequenceEditor.Repaint(); // Debug.Log( "AnimWindow->Flux: " + (animEvt.Start + animWindowFrame) ); } } } } }
public override void UpdateEventsEditor(int frame, float time) { if (Track.RequiresEditorCache && Track.CanPreview && !Track.HasCache) { Track.CanPreview = false; OnTogglePreview(true); } base.UpdateEventsEditor(frame, time); FEvent[] evts = new FEvent[2]; int numEvts = Track.GetEventsAt(frame, ref evts); if (numEvts > 0) { // if( AnimationMode.InAnimationMode() ) if (_syncWithAnimationWindow) //&& _track.IsPreviewing ) { // Debug.Log( SequenceEditor.OnUpdateEvent ); // AnimationMode.StartAnimationMode(); // System.Type t = typeof(EditorWindow).Assembly.GetType("UnityEditor.AnimationWindow"); // EditorWindow animWindow = EditorWindow.GetWindow( t ); // // // PropertyInfo stateProperty = t.GetProperty("state", BindingFlags.Instance | BindingFlags.Public); // object state = stateProperty.GetValue( animWindow, null ); // // Type stateT = typeof(EditorWindow).Assembly.GetType("UnityEditorInternal.AnimationWindowState"); // FieldInfo timeField = stateT.GetField("m_PlayTime"); // timeField.SetValue( state, time ); // // FieldInfo frameField = stateT.GetField("m_Frame"); // frameField.SetValue( state, frame ); // if( !AnimationMode.InAnimationMode() ) // AnimationMode.StartAnimationMode(); FPlayAnimationEvent animEvt = (FPlayAnimationEvent)evts[numEvts - 1]; AnimationWindowProxy.SelectAnimationClip(animEvt._animationClip); AnimationWindowProxy.SetCurrentFrame(frame - animEvt.Start, time - animEvt.StartTime); // Debug.Log("Flux->AnimWindow: " + (frame - animEvt.Start)); } } }