public static CutsceneWrapper CreateWrapper(Cutscene cutscene)
    {
        CutsceneWrapper wrapper = new CutsceneWrapper(cutscene);

        if (cutscene != null)
        {
            wrapper.RunningTime = cutscene.RunningTime;
            wrapper.Duration    = cutscene.Duration;
            wrapper.IsPlaying   = cutscene.State == Cutscene.CutsceneState.PreviewPlaying || cutscene.State == Cutscene.CutsceneState.Playing;

            foreach (TrackGroup tg in cutscene.TrackGroups)
            {
                TrackGroupWrapper tgWrapper = new TrackGroupWrapper(tg);
                tgWrapper.Ordinal = tg.Ordinal;
                wrapper.AddTrackGroup(tg, tgWrapper);

                foreach (TimelineTrack track in tg.GetTracks())
                {
                    TimelineTrackWrapper trackWrapper = new TimelineTrackWrapper(track);
                    trackWrapper.Ordinal = track.Ordinal;
                    tgWrapper.AddTrack(track, trackWrapper);

                    foreach (TimelineItem item in track.GetTimelineItems())
                    {
                        if (item.GetType().IsSubclassOf(typeof(CinemaClipCurve)))
                        {
                            CinemaClipCurve        clip        = item as CinemaClipCurve;
                            CinemaClipCurveWrapper clipWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration);
                            trackWrapper.AddItem(clip, clipWrapper);
                        }
                        else if (item.GetType().IsSubclassOf(typeof(CinemaTween)))
                        {
                        }
                        else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed)))
                        {
                            TimelineActionFixed      actionFixed        = item as TimelineActionFixed;
                            CinemaActionFixedWrapper actionFixedWrapper = new CinemaActionFixedWrapper(actionFixed, actionFixed.Firetime, actionFixed.Duration, actionFixed.InTime, actionFixed.OutTime, actionFixed.ItemLength);
                            trackWrapper.AddItem(actionFixed, actionFixedWrapper);
                        }
                        else if (item.GetType().IsSubclassOf(typeof(TimelineAction)))
                        {
                            TimelineAction      action      = item as TimelineAction;
                            CinemaActionWrapper itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration);
                            trackWrapper.AddItem(action, itemWrapper);
                        }
                        else
                        {
                            TimelineItemWrapper itemWrapper = new TimelineItemWrapper(item, item.Firetime);
                            trackWrapper.AddItem(item, itemWrapper);
                        }
                    }
                }
            }
        }
        return(wrapper);
    }
예제 #2
0
    void CinemaCurveControl_SnapScrubber(object sender, CurveClipScrubberEventArgs e)
    {
        CinemaClipCurve curveClip = e.curveClipItem as CinemaClipCurve;

        if (curveClip == null)
        {
            return;
        }

        curveClip.Cutscene.SetRunningTime(e.time);
    }
예제 #3
0
    void CinemaCurveControl_TranslateCurveClipItem(object sender, CurveClipItemEventArgs e)
    {
        CinemaClipCurve curveClip = e.curveClipItem as CinemaClipCurve;

        if (curveClip == null)
        {
            return;
        }

        Undo.RecordObject(e.curveClipItem, string.Format("Changed {0}", curveClip.name));
        curveClip.TranslateCurves(e.firetime - curveClip.Firetime);
    }
    void CinemaCurveControl_SnapScrubber(object sender, CurveClipScrubberEventArgs e)
    {
        CinemaClipCurve curveClip = e.curveClipItem as CinemaClipCurve;

        if (curveClip == null)
        {
            return;
        }

        curveClip.Cutscene.EnterPreviewMode(e.time);
        curveClip.Cutscene.SetRunningTime(e.time); // will always set running time even if already in preview mode.
    }
예제 #5
0
    private void pasteItem(object userData)
    {
        PasteContext data = userData as PasteContext;

        if (data != null)
        {
            float      firetime = (data.mousePosition.x - state.Translation.x) / state.Scale.x;
            GameObject clone    = DirectorCopyPaste.Paste(data.track.transform);

            CinemaClipCurve clipCurve = clone.GetComponent <CinemaClipCurve>();
            clipCurve.TranslateCurves(firetime - clipCurve.Firetime);

            Undo.RegisterCreatedObjectUndo(clone, "Pasted " + clone.name);
        }
    }
예제 #6
0
    void CinemaCurveControl_AlterDuration(object sender, CurveClipItemEventArgs e)
    {
        CinemaClipCurve curveClip = e.curveClipItem as CinemaClipCurve;

        if (curveClip == null)
        {
            return;
        }

        Undo.RecordObject(e.curveClipItem, string.Format("Changed {0}", curveClip.name));
        curveClip.AlterDuration(e.duration);

        if (e.duration <= 0)
        {
            GUIUtility.hotControl = 0;
            deleteItem(e.curveClipItem);
        }
    }
예제 #7
0
    protected virtual void CinemaCurveControl_CurvesChanged(object sender, CurveClipWrapperEventArgs e)
    {
        if (e.wrapper == null)
        {
            return;
        }
        CinemaClipCurveWrapper wrapper   = e.wrapper;
        CinemaClipCurve        clipCurve = wrapper.Behaviour as CinemaClipCurve;

        if (clipCurve == null)
        {
            return;
        }

        Undo.RecordObject(clipCurve, string.Format("Changed {0}", clipCurve.name));

        for (int i = 0; i < clipCurve.CurveData.Count; i++)
        {
            MemberClipCurveData member = clipCurve.CurveData[i];

            CinemaMemberCurveWrapper memberWrapper = null;
            if (wrapper.TryGetValue(member.Type, member.PropertyName, out memberWrapper))
            {
                int showingCurves = UnityPropertyTypeInfo.GetCurveCount(member.PropertyType);

                for (int j = 0; j < showingCurves; j++)
                {
                    member.SetCurve(j, new AnimationCurve(memberWrapper.AnimationCurves[j].Curve.keys));
                }
            }
        }

        clipCurve.Firetime = wrapper.Firetime;
        clipCurve.Duration = wrapper.Duration;

        EditorUtility.SetDirty(clipCurve);
    }
예제 #8
0
    public override void UpdateCurveWrappers(CinemaClipCurveWrapper clipWrapper)
    {
        CinemaClipCurve clipCurve = clipWrapper.Behaviour as CinemaClipCurve;

        if (clipCurve == null)
        {
            return;
        }

        for (int i = 0; i < clipCurve.CurveData.Count; i++)
        {
            MemberClipCurveData member = clipCurve.CurveData[i];

            CinemaMemberCurveWrapper memberWrapper = null;
            if (!clipWrapper.TryGetValue(member.Type, member.PropertyName, out memberWrapper))
            {
                memberWrapper              = new CinemaMemberCurveWrapper();
                memberWrapper.Type         = member.Type;
                memberWrapper.PropertyName = member.PropertyName;
                memberWrapper.Texture      = EditorGUIUtility.ObjectContent(null, UnityPropertyTypeInfo.GetUnityType(member.Type)).image;
                ArrayUtility.Add <CinemaMemberCurveWrapper>(ref clipWrapper.MemberCurves, memberWrapper);

                int showingCurves = UnityPropertyTypeInfo.GetCurveCount(member.PropertyType);
                memberWrapper.AnimationCurves = new CinemaAnimationCurveWrapper[showingCurves];

                for (int j = 0; j < showingCurves; j++)
                {
                    memberWrapper.AnimationCurves[j] = new CinemaAnimationCurveWrapper();

                    memberWrapper.AnimationCurves[j].Id    = j;
                    memberWrapper.AnimationCurves[j].Curve = new AnimationCurve(member.GetCurve(j).keys); // Make a deep copy.

                    memberWrapper.AnimationCurves[j].Label = UnityPropertyTypeInfo.GetCurveName(member.PropertyType, j);
                    memberWrapper.AnimationCurves[j].Color = UnityPropertyTypeInfo.GetCurveColor(member.Type, member.PropertyName, memberWrapper.AnimationCurves[j].Label, j);
                }
            }
            else
            {
                int showingCurves = UnityPropertyTypeInfo.GetCurveCount(member.PropertyType);
                for (int j = 0; j < showingCurves; j++)
                {
                    memberWrapper.AnimationCurves[j].Curve = new AnimationCurve(member.GetCurve(j).keys); // Make a deep copy.
                }
            }
        }

        // Remove missing track items
        List <CinemaMemberCurveWrapper> itemRemovals = new List <CinemaMemberCurveWrapper>();

        for (int i = 0; i < clipWrapper.MemberCurves.Length; i++)
        {
            CinemaMemberCurveWrapper cw = clipWrapper.MemberCurves[i];
            bool found = false;
            for (int j = 0; j < clipCurve.CurveData.Count; j++)
            {
                MemberClipCurveData member = clipCurve.CurveData[j];
                if (member.Type == cw.Type && member.PropertyName == cw.PropertyName)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                itemRemovals.Add(cw);
            }
        }
        for (int i = 0; i < itemRemovals.Count; i++)
        {
            ArrayUtility.Remove <CinemaMemberCurveWrapper>(ref clipWrapper.MemberCurves, itemRemovals[i]);
        }
    }
예제 #9
0
    public static CutsceneWrapper CreateWrapper(Cutscene cutscene)
    {
        CutsceneWrapper wrapper = new CutsceneWrapper(cutscene);

        if (cutscene != null)
        {
            wrapper.RunningTime = cutscene.RunningTime;
            wrapper.Duration    = cutscene.Duration;
            wrapper.IsPlaying   = cutscene.State == Cutscene.CutsceneState.PreviewPlaying || cutscene.State == Cutscene.CutsceneState.Playing;
            {
                var __array5       = cutscene.TrackGroups;
                var __arrayLength5 = __array5.Length;
                for (int __i5 = 0; __i5 < __arrayLength5; ++__i5)
                {
                    var tg = (TrackGroup)__array5[__i5];
                    {
                        TrackGroupWrapper tgWrapper = new TrackGroupWrapper(tg);
                        tgWrapper.Ordinal = tg.Ordinal;
                        wrapper.AddTrackGroup(tg, tgWrapper);
                        {
                            // foreach(var track in tg.GetTracks())
                            var __enumerator25 = (tg.GetTracks()).GetEnumerator();
                            while (__enumerator25.MoveNext())
                            {
                                var track = (TimelineTrack)__enumerator25.Current;
                                {
                                    TimelineTrackWrapper trackWrapper = new TimelineTrackWrapper(track);
                                    trackWrapper.Ordinal = track.Ordinal;
                                    tgWrapper.AddTrack(track, trackWrapper);
                                    {
                                        // foreach(var item in track.GetTimelineItems())
                                        var __enumerator33 = (track.GetTimelineItems()).GetEnumerator();
                                        while (__enumerator33.MoveNext())
                                        {
                                            var item = (TimelineItem)__enumerator33.Current;
                                            {
                                                if (item.GetType().IsSubclassOf(typeof(CinemaClipCurve)))
                                                {
                                                    CinemaClipCurve        clip        = item as CinemaClipCurve;
                                                    CinemaClipCurveWrapper clipWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration);
                                                    trackWrapper.AddItem(clip, clipWrapper);
                                                }
                                                else if (item.GetType().IsSubclassOf(typeof(CinemaTween)))
                                                {
                                                }
                                                else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed)))
                                                {
                                                    TimelineActionFixed      actionFixed        = item as TimelineActionFixed;
                                                    CinemaActionFixedWrapper actionFixedWrapper = new CinemaActionFixedWrapper(actionFixed, actionFixed.Firetime, actionFixed.Duration, actionFixed.InTime, actionFixed.OutTime, actionFixed.ItemLength);
                                                    trackWrapper.AddItem(actionFixed, actionFixedWrapper);
                                                }
                                                else if (item.GetType().IsSubclassOf(typeof(TimelineAction)))
                                                {
                                                    TimelineAction      action      = item as TimelineAction;
                                                    CinemaActionWrapper itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration);
                                                    trackWrapper.AddItem(action, itemWrapper);
                                                }
                                                else
                                                {
                                                    TimelineItemWrapper itemWrapper = new TimelineItemWrapper(item, item.Firetime);
                                                    trackWrapper.AddItem(item, itemWrapper);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return(wrapper);
    }
예제 #10
0
    public static CutsceneWrapper UpdateWrapper(Cutscene cutscene, CutsceneWrapper wrapper)
    {
        if (cutscene == null)
        {
            return(null);
        }

        if (wrapper == null || !cutscene.Equals(wrapper.Behaviour))
        {
            return(CreateWrapper(cutscene));
        }
        else
        {
            wrapper.Behaviour   = cutscene;
            wrapper.Duration    = cutscene.Duration;
            wrapper.IsPlaying   = cutscene.State == Cutscene.CutsceneState.PreviewPlaying || cutscene.State == Cutscene.CutsceneState.Playing;
            wrapper.RunningTime = cutscene.RunningTime;

            List <Behaviour> itemsToRemove = new List <Behaviour>();
            {
                // foreach(var behaviour in wrapper.Behaviours)
                var __enumerator1 = (wrapper.Behaviours).GetEnumerator();
                while (__enumerator1.MoveNext())
                {
                    var behaviour = (Behaviour)__enumerator1.Current;
                    {
                        bool found = false;
                        {
                            // foreach(var group in cutscene.TrackGroups)
                            var __enumerator14 = (cutscene.TrackGroups).GetEnumerator();
                            while (__enumerator14.MoveNext())
                            {
                                var group = (TrackGroup)__enumerator14.Current;
                                {
                                    if (behaviour.Equals(group))
                                    {
                                        found = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (!found || behaviour == null)
                        {
                            itemsToRemove.Add(behaviour);
                        }
                    }
                }
            }
            {
                var __list2      = itemsToRemove;
                var __listCount2 = __list2.Count;
                for (int __i2 = 0; __i2 < __listCount2; ++__i2)
                {
                    var trackGroup = (Behaviour)__list2[__i2];
                    {
                        wrapper.HasChanged = true;
                        wrapper.RemoveTrackGroup(trackGroup);
                    }
                }
            }
            {
                var __array3       = cutscene.TrackGroups;
                var __arrayLength3 = __array3.Length;
                for (int __i3 = 0; __i3 < __arrayLength3; ++__i3)
                {
                    var tg = (TrackGroup)__array3[__i3];
                    {
                        TrackGroupWrapper tgWrapper = null;
                        if (!wrapper.ContainsTrackGroup(tg, out tgWrapper))
                        {
                            tgWrapper         = new TrackGroupWrapper(tg);
                            tgWrapper.Ordinal = tg.Ordinal;
                            wrapper.AddTrackGroup(tg, tgWrapper);
                            wrapper.HasChanged = true;
                        }
                        {
                            // foreach(var track in tg.GetTracks())
                            var __enumerator19 = (tg.GetTracks()).GetEnumerator();
                            while (__enumerator19.MoveNext())
                            {
                                var track = (TimelineTrack)__enumerator19.Current;
                                {
                                    TimelineTrackWrapper trackWrapper = null;
                                    if (!tgWrapper.ContainsTrack(track, out trackWrapper))
                                    {
                                        trackWrapper         = new TimelineTrackWrapper(track);
                                        trackWrapper.Ordinal = track.Ordinal;
                                        tgWrapper.AddTrack(track, trackWrapper);
                                        tgWrapper.HasChanged = true;
                                    }
                                    {
                                        // foreach(var item in track.GetTimelineItems())
                                        var __enumerator28 = (track.GetTimelineItems()).GetEnumerator();
                                        while (__enumerator28.MoveNext())
                                        {
                                            var item = (TimelineItem)__enumerator28.Current;
                                            {
                                                TimelineItemWrapper itemWrapper = null;
                                                if (!trackWrapper.ContainsItem(item, out itemWrapper))
                                                {
                                                    if (item.GetType().IsSubclassOf(typeof(CinemaClipCurve)))
                                                    {
                                                        CinemaClipCurve clip = item as CinemaClipCurve;
                                                        itemWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration);
                                                        trackWrapper.AddItem(clip, itemWrapper);
                                                    }
                                                    else if (item.GetType().IsSubclassOf(typeof(CinemaTween)))
                                                    {
                                                        CinemaTween tween = item as CinemaTween;
                                                        itemWrapper = new CinemaTweenWrapper(tween, tween.Firetime, tween.Duration);
                                                        trackWrapper.AddItem(tween, itemWrapper);
                                                    }
                                                    else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed)))
                                                    {
                                                        TimelineActionFixed fixedAction = item as TimelineActionFixed;
                                                        itemWrapper = new CinemaActionFixedWrapper(fixedAction, fixedAction.Firetime, fixedAction.Duration, fixedAction.InTime, fixedAction.OutTime, fixedAction.ItemLength);
                                                        trackWrapper.AddItem(fixedAction, itemWrapper);
                                                    }
                                                    else if (item.GetType().IsSubclassOf(typeof(TimelineAction)))
                                                    {
                                                        TimelineAction action = item as TimelineAction;
                                                        itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration);
                                                        trackWrapper.AddItem(action, itemWrapper);
                                                    }
                                                    else
                                                    {
                                                        itemWrapper = new TimelineItemWrapper(item, item.Firetime);
                                                        trackWrapper.AddItem(item, itemWrapper);
                                                    }
                                                    trackWrapper.HasChanged = true;
                                                }
                                                else
                                                {
                                                    if (GUIUtility.hotControl == 0)
                                                    {
                                                        if (itemWrapper.GetType() == (typeof(CinemaClipCurveWrapper)))
                                                        {
                                                            CinemaClipCurve        clip        = item as CinemaClipCurve;
                                                            CinemaClipCurveWrapper clipWrapper = itemWrapper as CinemaClipCurveWrapper;
                                                            clipWrapper.Firetime = clip.Firetime;
                                                            clipWrapper.Duration = clip.Duration;
                                                        }
                                                        else if (itemWrapper.GetType() == (typeof(CinemaTweenWrapper)))
                                                        {
                                                        }
                                                        else if (itemWrapper.GetType() == (typeof(CinemaActionFixedWrapper)))
                                                        {
                                                            TimelineActionFixed      actionFixed        = item as TimelineActionFixed;
                                                            CinemaActionFixedWrapper actionFixedWrapper = itemWrapper as CinemaActionFixedWrapper;
                                                            actionFixedWrapper.Firetime   = actionFixed.Firetime;
                                                            actionFixedWrapper.Duration   = actionFixed.Duration;
                                                            actionFixedWrapper.InTime     = actionFixed.InTime;
                                                            actionFixedWrapper.OutTime    = actionFixed.OutTime;
                                                            actionFixedWrapper.ItemLength = actionFixed.ItemLength;
                                                        }
                                                        else if (itemWrapper.GetType() == (typeof(CinemaActionWrapper)))
                                                        {
                                                            TimelineAction      action        = item as TimelineAction;
                                                            CinemaActionWrapper actionWrapper = itemWrapper as CinemaActionWrapper;
                                                            actionWrapper.Firetime = action.Firetime;
                                                            actionWrapper.Duration = action.Duration;
                                                        }
                                                        else
                                                        {
                                                            itemWrapper.Firetime = item.Firetime;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    // Remove missing track items
                                    List <Behaviour> itemRemovals = new List <Behaviour>();
                                    {
                                        // foreach(var behaviour in trackWrapper.Behaviours)
                                        var __enumerator30 = (trackWrapper.Behaviours).GetEnumerator();
                                        while (__enumerator30.MoveNext())
                                        {
                                            var behaviour = (Behaviour)__enumerator30.Current;
                                            {
                                                bool found = false;
                                                {
                                                    var __array34       = track.GetTimelineItems();
                                                    var __arrayLength34 = __array34.Length;
                                                    for (int __i34 = 0; __i34 < __arrayLength34; ++__i34)
                                                    {
                                                        var item = (TimelineItem)__array34[__i34];
                                                        {
                                                            if (behaviour.Equals(item))
                                                            {
                                                                found = true;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                                if (!found || behaviour == null)
                                                {
                                                    itemRemovals.Add(behaviour);
                                                }
                                            }
                                        }
                                    }
                                    {
                                        var __list31      = itemRemovals;
                                        var __listCount31 = __list31.Count;
                                        for (int __i31 = 0; __i31 < __listCount31; ++__i31)
                                        {
                                            var item = (Behaviour)__list31[__i31];
                                            {
                                                trackWrapper.HasChanged = true;
                                                trackWrapper.RemoveItem(item);
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        // Remove missing tracks
                        List <Behaviour> removals = new List <Behaviour>();
                        {
                            // foreach(var behaviour in tgWrapper.Behaviours)
                            var __enumerator21 = (tgWrapper.Behaviours).GetEnumerator();
                            while (__enumerator21.MoveNext())
                            {
                                var behaviour = (Behaviour)__enumerator21.Current;
                                {
                                    bool found = false;
                                    {
                                        // foreach(var track in tg.GetTracks())
                                        var __enumerator32 = (tg.GetTracks()).GetEnumerator();
                                        while (__enumerator32.MoveNext())
                                        {
                                            var track = (TimelineTrack)__enumerator32.Current;
                                            {
                                                if (behaviour.Equals(track))
                                                {
                                                    found = true;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    if (!found || behaviour == null)
                                    {
                                        removals.Add(behaviour);
                                    }
                                }
                            }
                        }
                        {
                            var __list22      = removals;
                            var __listCount22 = __list22.Count;
                            for (int __i22 = 0; __i22 < __listCount22; ++__i22)
                            {
                                var track = (Behaviour)__list22[__i22];
                                {
                                    tgWrapper.HasChanged = true;
                                    tgWrapper.RemoveTrack(track);
                                }
                            }
                        }
                    }
                }
            }
        }

        return(wrapper);
    }
    public static CutsceneWrapper UpdateWrapper(Cutscene cutscene, CutsceneWrapper wrapper)
    {
        if (cutscene == null)
        {
            return(null);
        }

        if (wrapper == null || !cutscene.Equals(wrapper.Behaviour))
        {
            return(CreateWrapper(cutscene));
        }
        else
        {
            wrapper.Behaviour   = cutscene;
            wrapper.Duration    = cutscene.Duration;
            wrapper.IsPlaying   = cutscene.State == Cutscene.CutsceneState.PreviewPlaying || cutscene.State == Cutscene.CutsceneState.Playing;
            wrapper.RunningTime = cutscene.RunningTime;

            List <Behaviour> itemsToRemove = new List <Behaviour>();
            foreach (Behaviour behaviour in wrapper.Behaviours)
            {
                bool found = false;
                foreach (TrackGroup group in cutscene.TrackGroups)
                {
                    if (behaviour.Equals(group))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found || behaviour == null)
                {
                    itemsToRemove.Add(behaviour);
                }
            }

            foreach (Behaviour trackGroup in itemsToRemove)
            {
                wrapper.HasChanged = true;
                wrapper.RemoveTrackGroup(trackGroup);
            }

            foreach (TrackGroup tg in cutscene.TrackGroups)
            {
                TrackGroupWrapper tgWrapper = null;
                if (!wrapper.ContainsTrackGroup(tg, out tgWrapper))
                {
                    tgWrapper         = new TrackGroupWrapper(tg);
                    tgWrapper.Ordinal = tg.Ordinal;
                    wrapper.AddTrackGroup(tg, tgWrapper);
                    wrapper.HasChanged = true;
                }

                foreach (TimelineTrack track in tg.GetTracks())
                {
                    TimelineTrackWrapper trackWrapper = null;
                    if (!tgWrapper.ContainsTrack(track, out trackWrapper))
                    {
                        trackWrapper         = new TimelineTrackWrapper(track);
                        trackWrapper.Ordinal = track.Ordinal;
                        tgWrapper.AddTrack(track, trackWrapper);
                        tgWrapper.HasChanged = true;
                    }

                    foreach (TimelineItem item in track.GetTimelineItems())
                    {
                        TimelineItemWrapper itemWrapper = null;
                        if (!trackWrapper.ContainsItem(item, out itemWrapper))
                        {
                            if (item.GetType().IsSubclassOf(typeof(CinemaClipCurve)))
                            {
                                CinemaClipCurve clip = item as CinemaClipCurve;
                                itemWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration);
                                trackWrapper.AddItem(clip, itemWrapper);
                            }
                            else if (item.GetType().IsSubclassOf(typeof(CinemaTween)))
                            {
                                CinemaTween tween = item as CinemaTween;
                                itemWrapper = new CinemaTweenWrapper(tween, tween.Firetime, tween.Duration);
                                trackWrapper.AddItem(tween, itemWrapper);
                            }
                            else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed)))
                            {
                                TimelineActionFixed fixedAction = item as TimelineActionFixed;
                                itemWrapper = new CinemaActionFixedWrapper(fixedAction, fixedAction.Firetime, fixedAction.Duration, fixedAction.InTime, fixedAction.OutTime, fixedAction.ItemLength);
                                trackWrapper.AddItem(fixedAction, itemWrapper);
                            }
                            else if (item.GetType().IsSubclassOf(typeof(TimelineAction)))
                            {
                                TimelineAction action = item as TimelineAction;
                                itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration);
                                trackWrapper.AddItem(action, itemWrapper);
                            }
                            else
                            {
                                itemWrapper = new TimelineItemWrapper(item, item.Firetime);
                                trackWrapper.AddItem(item, itemWrapper);
                            }
                            trackWrapper.HasChanged = true;
                        }
                        else
                        {
                            if (GUIUtility.hotControl == 0)
                            {
                                if (itemWrapper.GetType() == (typeof(CinemaClipCurveWrapper)))
                                {
                                    CinemaClipCurve        clip        = item as CinemaClipCurve;
                                    CinemaClipCurveWrapper clipWrapper = itemWrapper as CinemaClipCurveWrapper;
                                    clipWrapper.Firetime = clip.Firetime;
                                    clipWrapper.Duration = clip.Duration;
                                }
                                else if (itemWrapper.GetType() == (typeof(CinemaTweenWrapper)))
                                {
                                }
                                else if (itemWrapper.GetType() == (typeof(CinemaActionFixedWrapper)))
                                {
                                    TimelineActionFixed      actionFixed        = item as TimelineActionFixed;
                                    CinemaActionFixedWrapper actionFixedWrapper = itemWrapper as CinemaActionFixedWrapper;
                                    actionFixedWrapper.Firetime   = actionFixed.Firetime;
                                    actionFixedWrapper.Duration   = actionFixed.Duration;
                                    actionFixedWrapper.InTime     = actionFixed.InTime;
                                    actionFixedWrapper.OutTime    = actionFixed.OutTime;
                                    actionFixedWrapper.ItemLength = actionFixed.ItemLength;
                                }
                                else if (itemWrapper.GetType() == (typeof(CinemaActionWrapper)))
                                {
                                    TimelineAction      action        = item as TimelineAction;
                                    CinemaActionWrapper actionWrapper = itemWrapper as CinemaActionWrapper;
                                    actionWrapper.Firetime = action.Firetime;
                                    actionWrapper.Duration = action.Duration;
                                }
                                else
                                {
                                    itemWrapper.Firetime = item.Firetime;
                                }
                            }
                        }
                    }

                    // Remove missing track items
                    List <Behaviour> itemRemovals = new List <Behaviour>();
                    foreach (Behaviour behaviour in trackWrapper.Behaviours)
                    {
                        bool found = false;
                        foreach (TimelineItem item in track.GetTimelineItems())
                        {
                            if (behaviour.Equals(item))
                            {
                                found = true;
                                break;
                            }
                        }
                        if (!found || behaviour == null)
                        {
                            itemRemovals.Add(behaviour);
                        }
                    }
                    foreach (Behaviour item in itemRemovals)
                    {
                        trackWrapper.HasChanged = true;
                        trackWrapper.RemoveItem(item);
                    }
                    trackWrapper.IsLocked = track.lockedStatus;
                }

                // Remove missing tracks
                List <Behaviour> removals = new List <Behaviour>();
                foreach (Behaviour behaviour in tgWrapper.Behaviours)
                {
                    bool found = false;
                    foreach (TimelineTrack track in tg.GetTracks())
                    {
                        if (behaviour.Equals(track))
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found || behaviour == null)
                    {
                        removals.Add(behaviour);
                    }
                }
                foreach (Behaviour track in removals)
                {
                    tgWrapper.HasChanged = true;
                    tgWrapper.RemoveTrack(track);
                }
            }
        }

        return(wrapper);
    }
예제 #12
0
    public override void UpdateCurveWrappers(CinemaClipCurveWrapper clipWrapper)
    {
        CinemaClipCurve clipCurve = clipWrapper.Behaviour as CinemaClipCurve;

        if (clipCurve == null)
        {
            return;
        }

        for (int i = 0; i < clipCurve.CurveData.Count; i++)
        {
            MemberClipCurveData member = clipCurve.CurveData[i];

            CinemaMemberCurveWrapper memberWrapper = null;
            if (!clipWrapper.TryGetValue(member.Type, member.PropertyName, out memberWrapper))
            {
                memberWrapper              = new CinemaMemberCurveWrapper();
                memberWrapper.Type         = member.Type;
                memberWrapper.PropertyName = member.PropertyName;
                memberWrapper.Texture      = EditorGUIUtility.ObjectContent(null, UnityPropertyTypeInfo.GetUnityType(member.Type)).image;
                ArrayUtility.Add <CinemaMemberCurveWrapper>(ref clipWrapper.MemberCurves, memberWrapper);

                int showingCurves = UnityPropertyTypeInfo.GetCurveCount(member.PropertyType);
                memberWrapper.AnimationCurves = new CinemaAnimationCurveWrapper[showingCurves];

                for (int j = 0; j < showingCurves; j++)
                {
                    memberWrapper.AnimationCurves[j] = new CinemaAnimationCurveWrapper();

                    memberWrapper.AnimationCurves[j].Id    = j;
                    memberWrapper.AnimationCurves[j].Curve = member.GetCurve(j);
                    memberWrapper.AnimationCurves[j].Label = UnityPropertyTypeInfo.GetCurveName(member.PropertyType, j);
                    memberWrapper.AnimationCurves[j].Color = UnityPropertyTypeInfo.GetCurveColor(member.Type, member.PropertyName, memberWrapper.AnimationCurves[j].Label, j);
                }
            }
        }

        // Remove missing track items
        List <CinemaMemberCurveWrapper> itemRemovals = new List <CinemaMemberCurveWrapper>();
        {
            // foreach(var cw in clipWrapper.MemberCurves)
            var __enumerator1 = (clipWrapper.MemberCurves).GetEnumerator();
            while (__enumerator1.MoveNext())
            {
                var cw = (CinemaMemberCurveWrapper)__enumerator1.Current;
                {
                    bool found = false;
                    {
                        // foreach(var member in clipCurve.CurveData)
                        var __enumerator3 = (clipCurve.CurveData).GetEnumerator();
                        while (__enumerator3.MoveNext())
                        {
                            var member = (MemberClipCurveData)__enumerator3.Current;
                            {
                                if (member.Type == cw.Type && member.PropertyName == cw.PropertyName)
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (!found)
                    {
                        itemRemovals.Add(cw);
                    }
                }
            }
        }
        {
            var __list2      = itemRemovals;
            var __listCount2 = __list2.Count;
            for (int __i2 = 0; __i2 < __listCount2; ++__i2)
            {
                var item = (CinemaMemberCurveWrapper)__list2[__i2];
                {
                    ArrayUtility.Remove <CinemaMemberCurveWrapper>(ref clipWrapper.MemberCurves, item);
                }
            }
        }
    }