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);
        }
        public static void SetEnd(TimelineClip clip, double time, bool affectTimeScale)
        {
            var duration = Math.Max(time - clip.start, TimelineClip.kMinDuration);

            if (affectTimeScale && clip.SupportsSpeedMultiplier())
            {
                var f = clip.duration / duration;
                clip.timeScale *= f;
            }

            clip.duration = duration;
        }
 public static bool HalfSpeed(TimelineClip[] clips)
 {
     for (int i = 0; i < clips.Length; i++)
     {
         TimelineClip timelineClip = clips[i];
         if (timelineClip.SupportsSpeedMultiplier())
         {
             TimelineUndo.PushUndo(timelineClip.parentTrack, "Half Clip Speed");
             timelineClip.timeScale *= 0.5;
             timelineClip.duration  *= 2.0;
         }
     }
     return(true);
 }
        public static void SetStart(TimelineClip clip, double time, bool affectTimeScale)
        {
            var  supportsClipIn     = clip.SupportsClipIn();
            var  supportsPadding    = TimelineUtility.IsRecordableAnimationClip(clip);
            bool calculateTimeScale = (affectTimeScale && clip.SupportsSpeedMultiplier());

            // 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 && !calculateTimeScale)
            {
                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 (calculateTimeScale)
            {
                var f = clip.duration / duration;
                clip.timeScale *= f;
            }


            if (supportsClipIn && !calculateTimeScale)
            {
                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;
        }