Пример #1
0
        private void UpdateDragTarget(TimelineClipGUI uiClip, Vector2 point, TimelineWindow.TimelineState state)
        {
            List <IBounds>   elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, point);
            TimelineTrackGUI timelineTrackGUI   = elementsAtPosition.OfType <TimelineTrackGUI>().FirstOrDefault((TimelineTrackGUI t) => MoveClip.ValidateClipDrag(t.track, uiClip.clip));

            this.m_HasValidDropTarget = (timelineTrackGUI != null && timelineTrackGUI.track.IsCompatibleWithItem(uiClip.clip));
            if (this.m_HasValidDropTarget)
            {
                AnimationTrack animationTrack = timelineTrackGUI.track as AnimationTrack;
                float          start          = state.PixelToTime(this.m_PreviewRect.get_x());
                float          end            = state.PixelToTime(this.m_PreviewRect.get_xMax());
                bool           hasValidDropTarget;
                if (animationTrack != null && animationTrack.CanConvertToClipMode())
                {
                    hasValidDropTarget = ((animationTrack.animClip.get_startTime() < start || animationTrack.animClip.get_stopTime() > end) && (start <animationTrack.animClip.get_startTime() || end> animationTrack.animClip.get_stopTime()));
                }
                else
                {
                    float num = end - start;
                    start = Math.Max(start, 0f);
                    end   = start + num;
                    hasValidDropTarget = (!timelineTrackGUI.track.clips.Any((TimelineClip x) => x.start >= (double)start && x.end <= (double)end) && !timelineTrackGUI.track.clips.Any((TimelineClip x) => (double)start >= x.start && (double)end <= x.end));
                }
                this.m_HasValidDropTarget = hasValidDropTarget;
            }
            this.m_DropTarget = ((!this.m_HasValidDropTarget) ? null : timelineTrackGUI);
        }
        public static bool Do(WindowState state, TrackAsset track)
        {
            AnimationClip clipToEdit = null;

            AnimationTrack animationTrack = track as AnimationTrack;

            if (animationTrack != null)
            {
                if (!animationTrack.CanConvertToClipMode())
                {
                    return(false);
                }

                clipToEdit = animationTrack.infiniteClip;
            }
            else if (track.hasCurves)
            {
                clipToEdit = track.curves;
            }

            if (clipToEdit == null)
            {
                return(false);
            }

            var gameObject     = state.GetSceneReference(track);
            var timeController = TimelineAnimationUtilities.CreateTimeController(state, CreateTimeControlClipData(track));

            TimelineAnimationUtilities.EditAnimationClipWithTimeController(clipToEdit, timeController, gameObject);

            return(true);
        }
 public static void ConvertToClipMode(this AnimationTrack track)
 {
     if (track.CanConvertToClipMode())
     {
         TimelineUndo.PushUndo(track, "Convert To Clip");
         if (!track.animClip.get_empty())
         {
             TimelineUndo.PushUndo(track.animClip, "Convert To Clip");
             float num = AnimationClipCurveCache.Instance.GetCurveInfo(track.animClip).keyTimes.FirstOrDefault <float>();
             track.animClip.ShiftBySeconds(-num);
             TimelineClip timelineClip = track.CreateClipFromAsset(track.animClip);
             TimelineCreateUtilities.SaveAssetIntoObject(timelineClip.asset, track);
             timelineClip.start = (double)num;
             timelineClip.preExtrapolationMode  = track.openClipPreExtrapolation;
             timelineClip.postExtrapolationMode = track.openClipPostExtrapolation;
             timelineClip.recordable            = true;
             if (Math.Abs(timelineClip.duration) < 1.4012984643248171E-45)
             {
                 timelineClip.duration = 1.0;
             }
             AnimationPlayableAsset animationPlayableAsset = timelineClip.asset as AnimationPlayableAsset;
             if (animationPlayableAsset)
             {
                 animationPlayableAsset.position = track.openClipOffsetPosition;
                 animationPlayableAsset.rotation = track.openClipOffsetRotation;
                 track.openClipOffsetPosition    = Vector3.get_zero();
                 track.openClipOffsetRotation    = Quaternion.get_identity();
             }
             track.CalculateExtrapolationTimes();
         }
         track.animClip = null;
         EditorUtility.SetDirty(track);
     }
 }
Пример #4
0
        public override void OnBuildTrackContextMenu(GenericMenu menu, TrackAsset track, ITimelineState state)
        {
            base.OnBuildTrackContextMenu(menu, track, state);
            bool           flag      = false;
            AnimationTrack animTrack = track as AnimationTrack;

            if (animTrack != null)
            {
                if (animTrack.CanConvertFromClipMode() || animTrack.CanConvertToClipMode())
                {
                    bool flag2 = animTrack.CanConvertFromClipMode();
                    bool flag3 = animTrack.CanConvertToClipMode();
                    if (flag2)
                    {
                        menu.AddItem(EditorGUIUtility.TextContent("Convert To Infinite Clip"), false, delegate(object parentTrack)
                        {
                            animTrack.ConvertFromClipMode(state.timeline);
                        }, track);
                        flag = true;
                    }
                    if (flag3)
                    {
                        menu.AddItem(EditorGUIUtility.TextContent("Convert To Clip Track"), false, delegate(object parentTrack)
                        {
                            animTrack.ConvertToClipMode();
                            state.Refresh();
                        }, track);
                    }
                }
            }
            if (!track.isSubTrack)
            {
                if (flag)
                {
                    menu.AddSeparator("");
                }
                menu.AddItem(EditorGUIUtility.TextContent("Add Override Track"), false, delegate(object parentTrack)
                {
                    AnimationTrackDrawer.AddSubTrack(state, typeof(AnimationTrack), "Override " + track.subTracks.Count.ToString(), track);
                }, track);
            }
        }
        internal static void ConvertToClipMode(this AnimationTrack track)
        {
            if (!track.CanConvertToClipMode())
            {
                return;
            }

            UndoExtensions.RegisterTrack(track, L10n.Tr("Convert To Clip"));

            if (!track.infiniteClip.empty)
            {
                var animClip = track.infiniteClip;
                TimelineUndo.PushUndo(animClip, L10n.Tr("Convert To Clip"));
                UndoExtensions.RegisterTrack(track, L10n.Tr("Convert To Clip"));
                var start = AnimationClipCurveCache.Instance.GetCurveInfo(animClip).keyTimes.FirstOrDefault();
                animClip.ShiftBySeconds(-start);

                track.infiniteClip = null;
                var clip = track.CreateClip(animClip);

                clip.start = start;
                clip.preExtrapolationMode  = track.infiniteClipPreExtrapolation;
                clip.postExtrapolationMode = track.infiniteClipPostExtrapolation;
                clip.recordable            = true;
                if (Mathf.Abs(animClip.length) < TimelineClip.kMinDuration)
                {
                    clip.duration = 1;
                }

                var animationAsset = clip.asset as AnimationPlayableAsset;
                if (animationAsset)
                {
                    animationAsset.position    = track.infiniteClipOffsetPosition;
                    animationAsset.eulerAngles = track.infiniteClipOffsetEulerAngles;

                    // going to / from infinite mode should reset this. infinite mode
                    animationAsset.removeStartOffset = track.infiniteClipRemoveOffset;
                    animationAsset.applyFootIK       = track.infiniteClipApplyFootIK;
                    animationAsset.loop = track.infiniteClipLoop;

                    track.infiniteClipOffsetPosition    = Vector3.zero;
                    track.infiniteClipOffsetEulerAngles = Vector3.zero;
                }

                track.CalculateExtrapolationTimes();
            }

            track.infiniteClip = null;

            EditorUtility.SetDirty(track);
        }
Пример #6
0
        public static bool Do(TimelineWindow.TimelineState state, TrackAsset track)
        {
            AnimationTrack animationTrack = track as AnimationTrack;
            bool           result;

            if (animationTrack == null)
            {
                result = false;
            }
            else if (!animationTrack.CanConvertToClipMode())
            {
                result = false;
            }
            else
            {
                Component bindingForTrack = state.GetBindingForTrack(animationTrack);
                TimelineWindowTimeControl timeController = TimelineAnimationUtilities.CreateTimeController(state, EditTrackInAnimationWindow.CreateTimeControlClipData(animationTrack));
                TimelineAnimationUtilities.EditAnimationClipWithTimeController(animationTrack.animClip, timeController, (!(bindingForTrack != null)) ? null : bindingForTrack.get_gameObject());
                result = true;
            }
            return(result);
        }
Пример #7
0
        public static bool Do(TrackAsset track)
        {
            AnimationClip clipToEdit = null;

            AnimationTrack animationTrack = track as AnimationTrack;

            if (animationTrack != null)
            {
                if (!animationTrack.CanConvertToClipMode())
                {
                    return(false);
                }

                clipToEdit = animationTrack.infiniteClip;
            }
            else if (track.hasCurves)
            {
                clipToEdit = track.curves;
            }

            if (clipToEdit == null)
            {
                return(false);
            }

            GameObject gameObject = null;

            if (TimelineEditor.inspectedDirector != null)
            {
                gameObject = TimelineUtility.GetSceneGameObject(TimelineEditor.inspectedDirector, track);
            }

            var timeController = TimelineAnimationUtilities.CreateTimeController(CreateTimeControlClipData(track));

            TimelineAnimationUtilities.EditAnimationClipWithTimeController(clipToEdit, timeController, gameObject);

            return(true);
        }
Пример #8
0
        public override MenuActionDisplayState GetDisplayState(TimelineWindow.TimelineState state, TrackAsset[] tracks)
        {
            MenuActionDisplayState result;

            if (tracks.Length == 0)
            {
                result = MenuActionDisplayState.Hidden;
            }
            else
            {
                if (tracks[0] is AnimationTrack)
                {
                    AnimationTrack track = tracks[0] as AnimationTrack;
                    if (track.CanConvertToClipMode())
                    {
                        result = MenuActionDisplayState.Visible;
                        return(result);
                    }
                }
                result = MenuActionDisplayState.Hidden;
            }
            return(result);
        }
Пример #9
0
            public void OnProcessScene(Scene scene)
            {
                IEnumerable <TimelineAsset> enumerable = (from pd in Object.FindObjectsOfType <PlayableDirector>()
                                                          select pd.get_playableAsset()).OfType <TimelineAsset>().Distinct <TimelineAsset>();

                foreach (TimelineAsset current in enumerable)
                {
                    if (TimelineAnalytics._timelineSceneInfo.uniqueDirectors.Add(current))
                    {
                        TimelineAnalytics._timelineSceneInfo.numTracks   += current.flattenedTracks.Count <TrackAsset>();
                        TimelineAnalytics._timelineSceneInfo.minDuration  = Math.Min(TimelineAnalytics._timelineSceneInfo.minDuration, (int)(current.get_duration() * 1000.0));
                        TimelineAnalytics._timelineSceneInfo.maxDuration  = Math.Max(TimelineAnalytics._timelineSceneInfo.maxDuration, (int)(current.get_duration() * 1000.0));
                        TimelineAnalytics._timelineSceneInfo.minNumTracks = Math.Min(TimelineAnalytics._timelineSceneInfo.minNumTracks, current.flattenedTracks.Count <TrackAsset>());
                        TimelineAnalytics._timelineSceneInfo.maxNumTracks = Math.Max(TimelineAnalytics._timelineSceneInfo.maxNumTracks, current.flattenedTracks.Count <TrackAsset>());
                        foreach (TrackAsset current2 in current.flattenedTracks)
                        {
                            string name = current2.GetType().Name;
                            if (TimelineAnalytics._timelineSceneInfo.trackCount.ContainsKey(name))
                            {
                                Dictionary <string, int> dictionary;
                                string key;
                                (dictionary = TimelineAnalytics._timelineSceneInfo.trackCount)[key = name] = dictionary[key] + 1;
                            }
                            else if (TimelineEventInfo.IsUserType(current2.GetType()))
                            {
                                Dictionary <string, int> dictionary;
                                (dictionary = TimelineAnalytics._timelineSceneInfo.trackCount)["UserType"] = dictionary["UserType"] + 1;
                                if (TimelineAnalytics._timelineSceneInfo.userTrackTypesCount.ContainsKey(name))
                                {
                                    string key2;
                                    (dictionary = TimelineAnalytics._timelineSceneInfo.userTrackTypesCount)[key2 = name] = dictionary[key2] + 1;
                                }
                                else
                                {
                                    TimelineAnalytics._timelineSceneInfo.userTrackTypesCount[name] = 1;
                                }
                            }
                            else
                            {
                                Dictionary <string, int> dictionary;
                                (dictionary = TimelineAnalytics._timelineSceneInfo.trackCount)["Other"] = dictionary["Other"] + 1;
                            }
                            if (current2.clips.Any((TimelineClip x) => x.recordable))
                            {
                                TimelineAnalytics._timelineSceneInfo.numRecorded++;
                            }
                            else
                            {
                                AnimationTrack animationTrack = current2 as AnimationTrack;
                                if (animationTrack != null)
                                {
                                    if (animationTrack.CanConvertToClipMode())
                                    {
                                        TimelineAnalytics._timelineSceneInfo.numRecorded++;
                                    }
                                }
                            }
                        }
                    }
                }
            }