Beispiel #1
0
        public void FinializeTrack(TrackAsset track, WindowState state)
        {
            // make sure we dirty the clip if we are in non clip mode
            var animTrack = track as AnimationTrack;

            if (!animTrack.inClipMode)
            {
                EditorUtility.SetDirty(animTrack.GetOrCreateClip());
            }

            // in clip mode we need to do some extra work
            if (recordClip != null)
            {
                // stretch the clip out to meet the new recording time
                if (m_ClipTime > recordClip.duration)
                {
                    UndoExtensions.RegisterTrack(track, "Add Key");
                    recordClip.duration = m_ClipTime;
                }

                track.CalculateExtrapolationTimes();
            }

            recordClip = null;
            m_ClipTime = 0;
            if (m_needRebuildRects)
            {
                state.CalculateRowRects();
                m_needRebuildRects = false;
            }
        }
Beispiel #2
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;
            }
        }
Beispiel #3
0
        public static TimelineClip CreateClipOnTrack(Object asset, TrackAsset parentTrack, ITimelineState state, Vector2 mousePosition)
        {
            double       end          = parentTrack.end;
            TimelineClip timelineClip = parentTrack.CreateClipFromAsset(asset);

            if (timelineClip != null)
            {
                SelectionManager.Clear();
                timelineClip.timeScale = 1.0;
                if (!float.IsPositiveInfinity(mousePosition.x) && !float.IsPositiveInfinity(mousePosition.y))
                {
                    timelineClip.start = (double)state.ScreenSpacePixelToTimeAreaTime(mousePosition.x);
                }
                else
                {
                    timelineClip.start = state.SnapToFrameIfRequired(end);
                }
                timelineClip.start       = Math.Max(0.0, timelineClip.start);
                timelineClip.mixInCurve  = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
                timelineClip.mixOutCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
                SelectionManager.Add(timelineClip);
                parentTrack.CalculateExtrapolationTimes();
                state.Refresh();
            }
            return(timelineClip);
        }
        internal static bool MoveClipToTrack(TimelineClip clip, TrackAsset track)
        {
            bool result;

            if (clip == null || track == null || clip.parentTrack == track)
            {
                result = false;
            }
            else
            {
                TimelineUndo.PushUndo(clip.parentTrack, "Move Clip");
                TimelineUndo.PushUndo(track, "Move Clip");
                AnimationTrack animationTrack = track as AnimationTrack;
                if (animationTrack != null)
                {
                    animationTrack.ConvertToClipMode();
                }
                TrackAsset parentTrack = clip.parentTrack;
                clip.parentTrack = track;
                parentTrack.CalculateExtrapolationTimes();
                result = true;
            }
            return(result);
        }