// public static EditorWindow GetAnimationWindow( bool showWindow ) // { // System.Type t = typeof(EditorWindow).Assembly.GetType("UnityEditor.AnimationWindow"); // if( showWindow ) // { // return EditorWindow.GetWindow( t ); // } // // System.Reflection.MethodInfo getWindow = typeof(EditorWindow).GetMethod( "GetWindowDontShow", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static ); // System.Reflection.MethodInfo getWindowGeneric = getWindow.MakeGenericMethod( t ); // return (EditorWindow)getWindowGeneric.Invoke(null, null); // } #endregion #region Upgrade Sequences public static void Upgrade(FSequence sequence) { const int fluxVersion = Flux.FUtility.FLUX_VERSION; if (sequence.Version == fluxVersion) { return; } Debug.LogFormat("Upgrading sequence '{0}' from version '{1}' to '{2}'", sequence.name, sequence.Version, fluxVersion); // is it before 2.0.0 release? if (sequence.Version < 200) { // set TimelineContainer as Content Transform timelineContainer = null; foreach (Transform t in sequence.transform) { if (t.name == "Timeline Container") { timelineContainer = t; break; } } if (timelineContainer == null) { timelineContainer = new GameObject("SequenceContent").transform; timelineContainer.hideFlags |= HideFlags.HideInHierarchy; } sequence.Content = timelineContainer; // create a container, and add it to the sequence FContainer container = FContainer.Create(FContainer.DEFAULT_COLOR); sequence.Add(container); FTimeline[] timelines = timelineContainer.GetComponentsInChildren <FTimeline>(); foreach (FTimeline timeline in timelines) { container.Add(timeline); List <FTrack> tracks = timeline.Tracks; foreach (FTrack track in tracks) { if (track is FAnimationTrack) { FAnimationTrack animTrack = (FAnimationTrack)track; if (animTrack.AnimatorController != null) { FAnimationTrackInspector inspector = (FAnimationTrackInspector)FAnimationTrackInspector.CreateEditor(animTrack); AnimatorController controller = (AnimatorController)animTrack.AnimatorController; inspector.UpdateLayer(controller == null || controller.layers.Length == 0 ? null : controller.layers[0]); inspector.serializedObject.ApplyModifiedProperties(); if (controller.layers.Length > 0) { while (controller.layers[0].stateMachine.stateMachines.Length > 0) { controller.layers[0].stateMachine.RemoveStateMachine(controller.layers[0].stateMachine.stateMachines[controller.layers[0].stateMachine.stateMachines.Length - 1].stateMachine); } while (controller.layers[0].stateMachine.states.Length > 0) { controller.layers[0].stateMachine.RemoveState(controller.layers[0].stateMachine.states[controller.layers[0].stateMachine.states.Length - 1].state); } } Editor.DestroyImmediate(inspector); FAnimationTrackInspector.RebuildStateMachine(animTrack); } } track.CacheMode = track.RequiredCacheMode; } // foreach( FTrack track in tracks ) // { // track.CacheType = track.DefaultCacheType(); // } } } sequence.Version = fluxVersion; }