Esempio n. 1
0
        public void FinializeTrack(TrackAsset track, TimelineWindow.TimelineState state)
        {
            AnimationTrack animationTrack = track as AnimationTrack;

            if (!animationTrack.inClipMode)
            {
                EditorUtility.SetDirty(animationTrack.GetOrCreateClip());
            }
            if (this.recordClip != null)
            {
                if (!this.m_ProcessedClips.Contains(this.recordClip.animationClip))
                {
                    this.m_ProcessedClips.Add(this.recordClip.animationClip);
                }
                if (this.m_ClipTime > this.recordClip.duration)
                {
                    TimelineUndo.PushUndo(track, "Add Key");
                    this.recordClip.duration = this.m_ClipTime;
                    this.m_RefreshState      = true;
                }
                track.CalculateExtrapolationTimes();
            }
            this.recordClip = null;
            this.m_ClipTime = 0.0;
            if (this.m_needRebuildRects)
            {
                state.CalculateRowRects();
                this.m_needRebuildRects = false;
            }
        }
Esempio n. 2
0
        public AnimationClip PrepareTrack(TrackAsset track, TimelineWindow.TimelineState state, GameObject gameObject, out double startTime)
        {
            AnimationTrack animationTrack = (AnimationTrack)track;
            AnimationClip  result;

            if (!animationTrack.inClipMode)
            {
                AnimationClip orCreateClip = animationTrack.GetOrCreateClip();
                startTime = (double)orCreateClip.get_frameRate() * state.time;
                if (!this.m_TracksToProcess.Contains(animationTrack))
                {
                    this.m_TracksToProcess.Add(animationTrack);
                }
                this.m_RebindList.Add(gameObject);
                if (orCreateClip.get_empty())
                {
                    animationTrack.openClipTimeOffset        = 0.0;
                    animationTrack.openClipPreExtrapolation  = TimelineClip.ClipExtrapolation.Hold;
                    animationTrack.openClipPostExtrapolation = TimelineClip.ClipExtrapolation.Hold;
                }
                result = orCreateClip;
            }
            else
            {
                TimelineClip timelineClip = AnimationTrackRecorder.GetRecordingClipForTrack(track, state);
                if (timelineClip == null)
                {
                    timelineClip = track.FindRecordingClipAtTime(state.time);
                }
                List <TimelineClip> list = (from x in track.clips
                                            where x.start <= state.time && x.end >= state.time
                                            select x).ToList <TimelineClip>();
                if (timelineClip == null)
                {
                    if (list.Count != 0)
                    {
                        if (list.Count > 0)
                        {
                            if (list.Any((TimelineClip x) => x.recordable))
                            {
                                goto IL_12A;
                            }
                        }
                        Debug.LogWarning("Cannot record on top of an imported animation clip");
                        startTime = -1.0;
                        result    = null;
                        return(result);
                    }
IL_12A:
                    timelineClip       = AnimationTrackRecorder.AddRecordableClip(track, state);
                    timelineClip.start = state.time;
                    this.m_RebindList.Add(gameObject);
                }
                AnimationClip animationClip = timelineClip.animationClip;
                double        num           = state.time - timelineClip.start;
                if (num < 0.0)
                {
                    Undo.RegisterCompleteObjectUndo(animationClip, "Record Key");
                    TimelineUndo.PushUndo(track, "Prepend Key");
                    AnimationTrackRecorder.ShiftAnimationClip(animationClip, (float)(-(float)num));
                    timelineClip.start     = state.time;
                    timelineClip.duration += -num;
                    num = 0.0;
                    this.m_RefreshState = true;
                }
                this.m_ClipTime         = num;
                this.recordClip         = timelineClip;
                startTime               = (double)TimeUtility.ToFrames(this.recordClip.ToLocalTimeUnbound(state.time), (double)animationClip.get_frameRate());
                this.m_needRebuildRects = animationClip.get_empty();
                result = animationClip;
            }
            return(result);
        }