void UpdateClipCaps(TimelineClip clip)
 {
     supportsBlending        &= clip.SupportsBlending();
     supportsClipIn          &= clip.SupportsClipIn();
     supportsExtrapolation   &= clip.SupportsExtrapolation();
     supportsSpeedMultiplier &= clip.SupportsSpeedMultiplier();
 }
        private ClipInspector.SelectionInfo BuildSelectionInfo()
        {
            ClipInspector.SelectionInfo result = new ClipInspector.SelectionInfo
            {
                supportsBlending        = true,
                supportsClipIn          = true,
                supportsExtrapolation   = true,
                supportsSpeedMultiplier = true,
                hasBlendIn  = true,
                hasBlendOut = true,
                selectedAssetTypesAreHomogeneous = true
            };
            HashSet <TrackAsset> hashSet = new HashSet <TrackAsset>();
            Object @object = (!this.m_SelectionCache.Any <ClipInspector.EditorClipSelection>()) ? null : this.m_SelectionCache.First <ClipInspector.EditorClipSelection>().clip.asset;
            Type   type    = (!(@object != null)) ? null : @object.GetType();

            foreach (ClipInspector.EditorClipSelection current in this.m_SelectionCache)
            {
                TimelineClip clip = current.clip;
                result.supportsBlending        &= clip.SupportsBlending();
                result.supportsClipIn          &= clip.SupportsClipIn();
                result.supportsExtrapolation   &= clip.SupportsExtrapolation();
                result.supportsSpeedMultiplier &= clip.SupportsSpeedMultiplier();
                result.hasBlendIn  &= clip.hasBlendIn;
                result.hasBlendOut &= clip.hasBlendOut;
                result.selectedAssetTypesAreHomogeneous &= (clip.asset.GetType() == type);
                hashSet.Add(clip.parentTrack);
            }
            result.selectionContainsAtLeastTwoClipsOnTheSameTrack = (hashSet.Count != this.m_SelectionCache.Count <ClipInspector.EditorClipSelection>());
            return(result);
        }
Example #3
0
        public TimelineClipGUI(TimelineClip clip, TimelineTrackGUI parent) : base(parent)
        {
            this.m_EditorItem  = EditorItemFactory.GetEditorClip(clip);
            clip.dirtyHash     = 0;
            this.supportResize = true;
            if (parent.drawer != null)
            {
                parent.drawer.ConfigureUIClip(this);
            }
            DragClipHandle clipHandleManipulator = (!clip.SupportsClipIn()) ? new SimpleDragClipHandle() : new DragClipHandle();

            this.m_LeftHandle     = new TimelineClipHandle(this, TimelineClipHandle.DragDirection.Left, clipHandleManipulator);
            this.m_RightHandle    = new TimelineClipHandle(this, TimelineClipHandle.DragDirection.Right, clipHandleManipulator);
            this.m_BlendInHandle  = new TimelineBlendHandle(this, TimelineBlendHandle.DragDirection.Left);
            this.m_BlendOutHandle = new TimelineBlendHandle(this, TimelineBlendHandle.DragDirection.Right);
            base.AddChild(this.m_LeftHandle);
            base.AddChild(this.m_RightHandle);
            base.AddChild(this.m_BlendInHandle);
            base.AddChild(this.m_BlendOutHandle);
            TimelineItemGUI.s_ItemToItemGUI[clip] = this;
        }
Example #4
0
        public static void SetStart(TimelineClip clip, double time)
        {
            var supportsClipIn  = clip.SupportsClipIn();
            var supportsPadding = TimelineUtility.IsRecordableAnimationClip(clip);

            // treat empty recordable clips as not supporting clip in (there are no keys to modify)
            if (supportsPadding && (clip.animationClip == null || clip.animationClip.empty))
            {
                supportsClipIn = false;
            }

            if (supportsClipIn && !supportsPadding)
            {
                var minStart = clip.FromLocalTimeUnbound(0.0);
                if (time < minStart)
                {
                    time = minStart;
                }
            }

            var maxStart = clip.end - TimelineClip.kMinDuration;

            if (time > maxStart)
            {
                time = maxStart;
            }

            var timeOffset = time - clip.start;
            var duration   = clip.duration - timeOffset;

            if (supportsClipIn)
            {
                if (supportsPadding)
                {
                    double clipInGlobal = clip.clipIn / clip.timeScale;
                    double keyShift     = -timeOffset;
                    if (timeOffset < 0) // left drag, eliminate clipIn before shifting
                    {
                        double clipInDelta = Math.Max(-clipInGlobal, timeOffset);
                        keyShift     = -Math.Min(0, timeOffset - clipInDelta);
                        clip.clipIn += clipInDelta * clip.timeScale;
                    }
                    else if (timeOffset > 0) // right drag, elimate padding in animation clip before adding clip in
                    {
                        var    clipInfo = AnimationClipCurveCache.Instance.GetCurveInfo(clip.animationClip);
                        double keyDelta = clip.FromLocalTimeUnbound(clipInfo.keyTimes.Min()) - clip.start;
                        keyShift     = -Math.Max(0, Math.Min(timeOffset, keyDelta));
                        clip.clipIn += Math.Max(timeOffset + keyShift, 0) * clip.timeScale;
                    }
                    if (keyShift != 0)
                    {
                        AnimationTrackRecorder.ShiftAnimationClip(clip.animationClip, (float)(keyShift * clip.timeScale));
                    }
                }
                else
                {
                    clip.clipIn += timeOffset * clip.timeScale;
                }
            }

            clip.start    = time;
            clip.duration = duration;
            clip.ConformEaseValues();
        }