Ejemplo n.º 1
0
    public override void DrawBackground(TimelineClip clip, ClipBackgroundRegion region)
    {
        base.DrawBackground(clip, region);

        if (Application.isPlaying || !TargetPositionCache.UseCache ||
            TargetPositionCache.CacheMode == TargetPositionCache.Mode.Disabled ||
            TimelineEditor.inspectedDirector == null)
        {
            return;
        }

        // Draw the cache indicator over the cached region
        var cacheRange = TargetPositionCache.CacheTimeRange;

        if (!cacheRange.IsEmpty)
        {
            cacheRange.Start = (float)TimelineGlobalToLocalTime(cacheRange.Start);
            cacheRange.End   = (float)TimelineGlobalToLocalTime(cacheRange.End);

            // Clip cacheRange to rect
            float start = (float)region.startTime;
            float end   = (float)region.endTime;
            cacheRange.Start = Mathf.Max((float)clip.ToLocalTime(cacheRange.Start), start);
            cacheRange.End   = Mathf.Min((float)clip.ToLocalTime(cacheRange.End), end);

            var r = region.position;
            var a = r.x + r.width * (cacheRange.Start - start) / (end - start);
            var b = r.x + r.width * (cacheRange.End - start) / (end - start);
            r.x  = a; r.width = b - a;
            r.y += r.height; r.height *= 0.2f; r.y -= r.height;
            EditorGUI.DrawRect(r, new Color(0.1f, 0.2f, 0.8f, 0.6f));
        }

        // Draw the "UNCACHED" indicator, if appropriate
        if (!TargetPositionCache.IsRecording && !TargetPositionCache.CurrentPlaybackTimeValid)
        {
            var r   = region.position;
            var t   = clip.ToLocalTime(TimelineGlobalToLocalTime(TimelineEditor.masterDirector.time));
            var pos = r.x + r.width
                      * (float)((t - region.startTime) / (region.endTime - region.startTime));

            var s = EditorStyles.miniLabel.CalcSize(kUndamped);
            r.width = s.x; r.x = pos - r.width / 2;
            var c = GUI.color;
            GUI.color = Color.yellow;
            EditorGUI.LabelField(r, kUndamped, EditorStyles.miniLabel);
            GUI.color = c;
        }
    }
Ejemplo n.º 2
0
//----------------------------------------------------------------------------------------------------------------------
    protected override void ProcessActiveClipV(FaderPlayableAsset asset, 
        double directorTime, TimelineClip activeClip) 
    {
        if (null == m_image)
            return;

        double localTime = activeClip.ToLocalTime(directorTime);
        
        Color color = asset.GetColor();
        float maxFade = color.a;

        float fade = (float)( ((localTime) / activeClip.duration ) * maxFade);
        if ( asset.GetFadeType() == FadeType.FADE_OUT) {
            fade = maxFade - fade;
        }

        color.a = fade;
        m_image.color = color;
    }
//----------------------------------------------------------------------------------------------------------------------

        //Calculate the used image index for the passed globalTime
        internal int GlobalTimeToImageIndex(TimelineClip clip, double globalTime)
        {
            double localTime = clip.ToLocalTime(globalTime);

            return(LocalTimeToImageIndex(clip, localTime));
        }
Ejemplo n.º 4
0
        private static void PreparePlayableAsset(ClipInspector.EditorClipSelection selectedItem)
        {
            if (Event.get_current().get_type() == 7)
            {
                if (selectedItem.playableAssetObject != null)
                {
                    TimelineClip clip = selectedItem.clip;
                    if (clip != null && !(clip.curves == null))
                    {
                        TimelineWindow instance = TimelineWindow.instance;
                        if (!(instance == null) && instance.state != null)
                        {
                            if (!instance.state.previewMode)
                            {
                                selectedItem.lastEvalTime = -1.0;
                            }
                            else
                            {
                                double num = instance.state.time;
                                num = clip.ToLocalTime(num);
                                if (selectedItem.lastEvalTime == num)
                                {
                                    int version = AnimationClipCurveCache.Instance.GetCurveInfo(clip.curves).version;
                                    if (version == selectedItem.lastCurveVersion)
                                    {
                                        return;
                                    }
                                    selectedItem.lastCurveVersion = version;
                                }
                                selectedItem.lastEvalTime = num;
                                AnimationClipCurveInfo curveInfo = AnimationClipCurveCache.Instance.GetCurveInfo(clip.curves);
                                if (curveInfo.bindings.Length != 0)
                                {
                                    selectedItem.playableAssetObject.Update();
                                    SerializedProperty iterator = selectedItem.playableAssetObject.GetIterator();
                                    while (iterator.NextVisible(true))
                                    {
                                        if (clip.IsParameterAnimated(iterator.get_propertyPath()))
                                        {
                                            AnimationCurve         animatedParameter = clip.GetAnimatedParameter(iterator.get_propertyPath());
                                            SerializedPropertyType propertyType      = iterator.get_propertyType();
                                            switch (propertyType)
                                            {
                                            case 0:
                                                iterator.set_intValue(Mathf.FloorToInt(animatedParameter.Evaluate((float)num)));
                                                continue;

                                            case 1:
                                                iterator.set_boolValue(animatedParameter.Evaluate((float)num) > 0f);
                                                continue;

                                            case 2:
                                                iterator.set_floatValue(animatedParameter.Evaluate((float)num));
                                                continue;

                                            case 3:
                                            case 5:
                                            case 6:
                                            case 7:
IL_18C:
                                                if (propertyType != 17)
                                                {
                                                    continue;
                                                }
                                                goto IL_222;

                                            case 4:
                                                ClipInspector.SetAnimatedValue(clip, iterator, "r", num);
                                                ClipInspector.SetAnimatedValue(clip, iterator, "g", num);
                                                ClipInspector.SetAnimatedValue(clip, iterator, "b", num);
                                                ClipInspector.SetAnimatedValue(clip, iterator, "a", num);
                                                continue;

                                            case 8:
                                                goto IL_248;

                                            case 9:
                                                goto IL_235;

                                            case 10:
                                                goto IL_222;
                                            }
                                            goto IL_18C;
                                            continue;
IL_248:
                                            ClipInspector.SetAnimatedValue(clip, iterator, "x", num);
                                            ClipInspector.SetAnimatedValue(clip, iterator, "y", num);
                                            continue;
IL_235:
                                            ClipInspector.SetAnimatedValue(clip, iterator, "z", num);
                                            goto IL_248;
IL_222:
                                            ClipInspector.SetAnimatedValue(clip, iterator, "w", num);
                                            goto IL_235;
                                        }
                                    }
                                    selectedItem.playableAssetObject.ApplyModifiedPropertiesWithoutUndo();
                                }
                            }
                        }
                    }
                }
            }
        }