예제 #1
0
        public static TimelineClip Clone(TimelineClip clip, PlayableDirector directorInstance)
        {
            EditorClip   editorClip = EditorItemFactory.GetEditorClip(clip);
            TimelineClip clip2      = Object.Instantiate <EditorClip>(editorClip).clip;

            SelectionManager.Remove(clip2);
            clip2.parentTrack = null;
            clip2.ClearAnimatedParameterCurves();
            if (clip.curves != null)
            {
                AnimatedParameterExtensions.CreateCurvesIfRequired(clip2, clip.parentTrack);
                EditorUtility.CopySerialized(clip.curves, clip2.curves);
            }
            ScriptableObject scriptableObject = clip2.asset as ScriptableObject;

            if (scriptableObject != null && clip2.asset is IPlayableAsset)
            {
                ScriptableObject scriptableObject2 = TimelineHelpers.CloneReferencedPlayableAsset(scriptableObject, directorInstance);
                TimelineHelpers.SaveCloneToOriginalAsset(scriptableObject, scriptableObject2);
                clip2.asset = scriptableObject2;
                AnimationPlayableAsset animationPlayableAsset = scriptableObject2 as AnimationPlayableAsset;
                if (clip2.recordable && animationPlayableAsset != null && animationPlayableAsset.clip != null)
                {
                    clip2.displayName = animationPlayableAsset.clip.get_name();
                }
            }
            return(clip2);
        }
예제 #2
0
        void ItemDoubleClickedCallback(int id)
        {
            var trackGUI = m_TreeView.FindItem(id) as TimelineTrackGUI;

            if (trackGUI == null)
            {
                return;
            }

            if (trackGUI.track == null || trackGUI.track.lockedInHierarchy)
            {
                return;
            }

            var selection      = SelectionManager.SelectedItems().ToList();
            var items          = ItemsUtils.GetItems(trackGUI.track).ToList();
            var addToSelection = !selection.SequenceEqual(items);

            foreach (var i in items)
            {
                if (addToSelection)
                {
                    SelectionManager.Add(i);
                }
                else
                {
                    SelectionManager.Remove(i);
                }
            }
        }
        private static void HandleSingleSelection(Event evt, TimelineWindow.TimelineState state, List <IBounds> elements)
        {
            if (RectangleSelect.CanClearSelection(evt))
            {
                SelectionManager.Clear();
            }
            TimelineItemGUI timelineItemGUI = RectangleSelect.PickItemGUI(elements);

            if (evt.get_modifiers() == 1)
            {
                timelineItemGUI.parentTrackGUI.RangeSelectItems(timelineItemGUI, state);
            }
            else if (evt.get_modifiers() == 2 || evt.get_modifiers() == 8)
            {
                bool flag = SelectionManager.Contains(timelineItemGUI.item);
                if (flag)
                {
                    SelectionManager.Remove(timelineItemGUI.item);
                }
                else
                {
                    SelectionManager.Add(timelineItemGUI.item);
                }
            }
            else
            {
                SelectionManager.Add(timelineItemGUI.item);
            }
        }
        public static bool SelectLeftItem(bool shift = false)
        {
            if (ClipAreaActive())
            {
                var items    = SelectionManager.SelectedItems().ToList();
                var clipOnly = FilterItems(ref items);

                var item = items.Last();
                var prev = item.PreviousItem(clipOnly);
                if (prev != null)
                {
                    if (shift)
                    {
                        if (SelectionManager.Contains(prev))
                        {
                            SelectionManager.Remove(item);
                        }
                        SelectionManager.Add(prev);
                    }
                    else
                    {
                        SelectionManager.SelectOnly(prev);
                    }
                    TimelineHelpers.FrameItems(new[] { prev });
                }
                else if (item != null && !shift && item.parentTrack != TimelineEditor.inspectedAsset.markerTrack)
                {
                    SelectionManager.SelectOnly(item.parentTrack);
                }
                return(true);
            }
            return(false);
        }
        internal void ItemDoubleClickedCallback(int id)
        {
            var gui      = m_TreeView.FindItem(id);
            var trackGUI = gui as TimelineTrackGUI;

            if (trackGUI != null)
            {
                if (trackGUI.track == null || trackGUI.track.lockedInHierarchy)
                {
                    return;
                }
                var selection      = SelectionManager.SelectedItems().ToList();
                var items          = ItemsUtils.GetItems(trackGUI.track).ToList();
                var addToSelection = !selection.SequenceEqual(items);

                foreach (var i in items)
                {
                    if (addToSelection)
                    {
                        SelectionManager.Add(i);
                    }
                    else
                    {
                        SelectionManager.Remove(i);
                    }
                }

                return;
            }

            if (gui is TimelineGroupGUI groupGUI)
            {
                KeyboardNavigation.ToggleCollapseGroup(new[] { groupGUI.track });
            }
        }
        public static bool SelectRightItem(bool shift = false)
        {
            if (ClipAreaActive())
            {
                var items    = SelectionManager.SelectedItems().ToList();
                var clipOnly = FilterItems(ref items);

                var item = items.Last();
                var next = item.NextItem(clipOnly);
                if (next != null)
                {
                    if (shift)
                    {
                        if (SelectionManager.Contains(next))
                        {
                            SelectionManager.Remove(item);
                        }
                        SelectionManager.Add(next);
                    }
                    else
                    {
                        SelectionManager.SelectOnly(next);
                    }
                    TimelineHelpers.FrameItems(new[] { next });
                    return(true);
                }
            }
            return(false);
        }
 public static bool SelectUpTrack(bool shift = false)
 {
     if (TrackHeadActive())
     {
         var prevTrack = PreviousTrack(SelectionManager.SelectedTracks().Last());
         if (prevTrack != null)
         {
             if (shift)
             {
                 if (SelectionManager.Contains(prevTrack))
                 {
                     SelectionManager.Remove(SelectionManager.SelectedTracks().Last());
                 }
                 SelectionManager.Add(prevTrack);
             }
             else
             {
                 SelectionManager.SelectOnly(prevTrack);
             }
             FrameTrackHeader(GetVisibleTracks().First(x => x.track == prevTrack));
         }
         return(true);
     }
     return(false);
 }
        public static bool SelectDownTrack(bool shift = false)
        {
            if (TrackHeadActive())
            {
                var nextTrack = SelectionManager.SelectedTracks().Last().NextTrack();
                if (nextTrack != null)
                {
                    if (shift)
                    {
                        if (SelectionManager.Contains(nextTrack))
                        {
                            SelectionManager.Remove(SelectionManager.SelectedTracks().Last());
                        }
                        SelectionManager.Add(nextTrack);
                    }
                    else
                    {
                        SelectionManager.SelectOnly(nextTrack);
                    }

                    FrameTrackHeader(GetVisibleTracks().First(x => x.track == nextTrack));
                }
                return(true);
            }

            return(false);
        }
예제 #9
0
 public override void Deselect()
 {
     SelectionManager.Remove(clip);
     if (inlineCurvesSelected)
     {
         SelectionManager.SelectInlineCurveEditor(null);
     }
 }
예제 #10
0
 void UnSelectMarkerOnHeaderTrack()
 {
     foreach (IMarker marker in SelectionManager.SelectedMarkers())
     {
         if (marker.parent == editSequence.asset.markerTrack)
         {
             SelectionManager.Remove(marker);
         }
     }
 }
예제 #11
0
        public static void DeleteMarker(IMarker marker)
        {
            var trackAsset = marker.parent;

            if (trackAsset != null)
            {
                SelectionManager.Remove(marker);
                trackAsset.DeleteMarker(marker);
            }
        }
예제 #12
0
        public static void SetLockState(TrackAsset[] tracks, bool shouldLock, WindowState state = null)
        {
            if (tracks.Length == 0)
            {
                return;
            }

            foreach (var track in tracks)
            {
                if (TimelineUtility.IsLockedFromGroup(track))
                {
                    continue;
                }

                if (track as GroupTrack == null)
                {
                    SetLockState(track.GetChildTracks().ToArray(), shouldLock, state);
                }

                TimelineUndo.PushUndo(track, "Lock Tracks");
                track.locked = shouldLock;
            }

            if (state != null)
            {
                // find the tracks we've locked. unselect anything locked and remove recording.
                foreach (var track in tracks)
                {
                    if (TimelineUtility.IsLockedFromGroup(track) || !track.locked)
                    {
                        continue;
                    }

                    var flattenedChildTracks = track.GetFlattenedChildTracks();
                    foreach (var i in track.clips)
                    {
                        SelectionManager.Remove(i);
                    }
                    state.UnarmForRecord(track);
                    foreach (var child in flattenedChildTracks)
                    {
                        SelectionManager.Remove(child);
                        state.UnarmForRecord(child);
                        foreach (var clip in child.GetClips())
                        {
                            SelectionManager.Remove(clip);
                        }
                    }
                }

                // no need to rebuild, just repaint (including inspectors)
                InspectorWindow.RepaintAllInspectors();
                state.editorWindow.Repaint();
            }
        }
예제 #13
0
        public static void SetLockState(IEnumerable <TrackAsset> tracks, bool shouldLock)
        {
            if (!tracks.Any())
            {
                return;
            }

            foreach (var track in tracks)
            {
                if (TimelineUtility.IsLockedFromGroup(track))
                {
                    continue;
                }

                if (track as GroupTrack == null)
                {
                    SetLockState(track.GetChildTracks().ToArray(), shouldLock);
                }

                TimelineUndo.PushUndo(track, L10n.Tr("Lock Tracks"));
                track.locked = shouldLock;
            }

            // find the tracks we've locked. unselect anything locked and remove recording.
            foreach (var track in tracks)
            {
                if (TimelineUtility.IsLockedFromGroup(track) || !track.locked)
                {
                    continue;
                }

                var flattenedChildTracks = track.GetFlattenedChildTracks();
                foreach (var i in track.clips)
                {
                    SelectionManager.Remove(i);
                }
                track.UnarmForRecord();
                foreach (var child in flattenedChildTracks)
                {
                    SelectionManager.Remove(child);
                    child.UnarmForRecord();
                    foreach (var clip in child.GetClips())
                    {
                        SelectionManager.Remove(clip);
                    }
                }
            }

            // no need to rebuild, just repaint (including inspectors)
            InspectorWindow.RepaintAllInspectors();
            TimelineEditor.Refresh(RefreshReason.WindowNeedsRedraw);
        }
예제 #14
0
 protected override void OnLockedChanged(bool value)
 {
     TimelineWindow.TimelineState state = TimelineWindow.instance.state;
     if (!base.locked)
     {
         foreach (TimelineItemGUI current in this.items)
         {
             SelectionManager.Remove(current.item);
         }
     }
     if (base.locked)
     {
         state.UnarmForRecord(base.track);
     }
 }
 static void ValidateSelection()
 {
     //get all the clips in the selection
     var selectedClips = Selection.GetFiltered<EditorClip>(SelectionMode.Unfiltered).Select(x => x.clip);
     foreach (var selectedClip in selectedClips)
     {
         var parent = selectedClip.parentTrack;
         if (selectedClip.parentTrack != null)
         {
             if (!parent.clips.Contains(selectedClip))
             {
                 SelectionManager.Remove(selectedClip);
             }
         }
     }
 }
예제 #16
0
        public static TrackAsset Clone(PlayableAsset parent, TrackAsset trackAsset, PlayableDirector directorInstance)
        {
            TrackAsset result;

            if (trackAsset == null)
            {
                result = null;
            }
            else
            {
                TimelineAsset timelineAsset = trackAsset.timelineAsset;
                if (timelineAsset == null)
                {
                    result = null;
                }
                else
                {
                    TrackAsset trackAsset2 = Object.Instantiate <TrackAsset>(trackAsset);
                    trackAsset2.SetClips(new List <TimelineClip>());
                    trackAsset2.parent    = parent;
                    trackAsset2.subTracks = new List <TrackAsset>();
                    string[] array = (from x in timelineAsset.flattenedTracks
                                      select x.get_name()).ToArray <string>();
                    trackAsset2.set_name(ObjectNames.GetUniqueName(array, trackAsset.get_name()));
                    if (trackAsset.animClip != null)
                    {
                        trackAsset2.animClip = TimelineHelpers.CloneAnimationClipIfRequired(trackAsset.animClip, trackAsset);
                    }
                    TimelineClip[] clips = trackAsset.clips;
                    for (int i = 0; i < clips.Length; i++)
                    {
                        TimelineClip clip         = clips[i];
                        TimelineClip timelineClip = TimelineHelpers.Clone(clip, directorInstance);
                        timelineClip.parentTrack = trackAsset2;
                        trackAsset2.AddClip(timelineClip);
                    }
                    trackAsset2.SetCollapsed(trackAsset.GetCollapsed());
                    if (SelectionManager.Contains(trackAsset))
                    {
                        SelectionManager.Remove(trackAsset);
                        SelectionManager.Add(trackAsset2);
                    }
                    result = trackAsset2;
                }
            }
            return(result);
        }
예제 #17
0
        internal static TimelineClip Clone(TimelineClip clip, PlayableDirector director, PlayableAsset newOwner)
        {
            var editorClip = EditorClipFactory.GetEditorClip(clip);
            // Workaround for Clips not being unity object, assign it to a editor clip wrapper, clone it, and pull the clip back out
            var newClip = Object.Instantiate(editorClip).clip;

            // perform fix ups for what Instantiate cannot properly detect
            SelectionManager.Remove(newClip);
            newClip.parentTrack = null;
            newClip.curves      = null; // instantiate might copy the reference, we need to clear it

            // curves are explicitly owned by the clip
            if (clip.curves != null)
            {
                newClip.CreateCurves(AnimationTrackRecorder.GetUniqueRecordedClipName(newOwner, clip.curves.name));
                EditorUtility.CopySerialized(clip.curves, newClip.curves);
                TimelineCreateUtilities.SaveAssetIntoObject(newClip.curves, newOwner);
            }

            ScriptableObject playableAsset = newClip.asset as ScriptableObject;

            if (playableAsset != null && newClip.asset is IPlayableAsset)
            {
                var clone = CloneReferencedPlayableAsset(playableAsset, director);
                SaveCloneToAsset(clone, newOwner);

                newClip.asset = clone;

                // special case to make the name match the recordable clips, but only if they match on the original clip
                var originalRecordedAsset = clip.asset as AnimationPlayableAsset;
                if (clip.recordable && originalRecordedAsset != null && originalRecordedAsset.clip != null)
                {
                    AnimationPlayableAsset clonedAnimationAsset = clone as AnimationPlayableAsset;
                    if (clonedAnimationAsset != null && clonedAnimationAsset.clip != null)
                    {
                        clonedAnimationAsset.clip = CloneAnimationClip(originalRecordedAsset.clip, newOwner);
                        if (clip.displayName == originalRecordedAsset.clip.name && newClip.recordable)
                        {
                            clonedAnimationAsset.name = clonedAnimationAsset.clip.name;
                            newClip.displayName       = clonedAnimationAsset.name;
                        }
                    }
                }
            }

            return(newClip);
        }
예제 #18
0
        public static void Remove(ITimelineItem item)
        {
            TimelineClip timelineClip = item as TimelineClip;

            if (timelineClip != null)
            {
                SelectionManager.Remove(timelineClip);
            }
            else
            {
                TimelineMarker timelineMarker = item as TimelineMarker;
                if (timelineMarker != null)
                {
                    SelectionManager.Remove(timelineMarker);
                }
            }
        }
        internal void SetShowTrackMarkers(TrackAsset track, bool showMarkerHeader)
        {
            var currentValue = track.GetShowMarkers();

            if (currentValue != showMarkerHeader)
            {
                TimelineUndo.PushUndo(state.editSequence.viewModel, "Toggle Show Markers");
                track.SetShowMarkers(showMarkerHeader);
                if (!showMarkerHeader)
                {
                    foreach (var marker in track.GetMarkers())
                    {
                        SelectionManager.Remove(marker);
                    }
                }
            }
        }
        internal static void SetShowTrackMarkers(this TrackAsset track, bool showMarkers)
        {
            var currentValue = track.GetShowMarkers();

            if (currentValue != showMarkers)
            {
                TimelineUndo.PushUndo(TimelineWindow.instance.state.editSequence.viewModel, L10n.Tr("Toggle Show Markers"));
                track.SetShowMarkers(showMarkers);
                if (!showMarkers)
                {
                    foreach (var marker in track.GetMarkers())
                    {
                        SelectionManager.Remove(marker);
                    }
                }
            }
        }
예제 #21
0
        public void RangeSelectItems(TimelineItemGUI lastItemToSelect, TimelineWindow.TimelineState state)
        {
            List <TimelineItemGUI> source          = SelectionManager.SelectedItemGUI().ToList <TimelineItemGUI>();
            TimelineItemGUI        timelineItemGUI = source.FirstOrDefault <TimelineItemGUI>();

            if (timelineItemGUI == null)
            {
                SelectionManager.Add(lastItemToSelect.item);
            }
            else
            {
                List <TimelineTrackBaseGUI> allTracks = TimelineWindow.instance.allTracks;
                List <TimelineItemGUI>      list      = allTracks.OfType <TimelineTrackGUI>().SelectMany((TimelineTrackGUI ttGui) => from x in ttGui.items
                                                                                                         orderby x.item.start
                                                                                                         select x).ToList <TimelineItemGUI>();
                int             num  = list.IndexOf(timelineItemGUI);
                TimelineItemGUI item = source.LastOrDefault <TimelineItemGUI>();
                int             num2 = list.IndexOf(item);
                int             num3 = list.IndexOf(lastItemToSelect);
                if (num < num3)
                {
                    for (int i = num; i <= num3; i++)
                    {
                        SelectionManager.Add(list[i].item);
                    }
                }
                else
                {
                    for (int j = num; j >= num3; j--)
                    {
                        SelectionManager.Add(list[j].item);
                    }
                }
                if (Math.Min(num, num2) < num3 && num3 < Math.Max(num, num2))
                {
                    for (int k = Math.Min(num2, num3); k <= Math.Max(num2, num3); k++)
                    {
                        SelectionManager.Remove(list[k].item);
                    }
                }
                SelectionManager.Add(lastItemToSelect.item);
            }
        }
        internal void SetShowMarkerHeader(bool newValue)
        {
            if (state.showMarkerHeader == newValue)
            {
                return;
            }

            TimelineUndo.PushUndo(state.editSequence.viewModel, "Toggle Show Markers");
            state.showMarkerHeader = newValue;
            if (!newValue)
            {
                var asset = state.editSequence.asset;
                if (asset != null && asset.markerTrack != null)
                {
                    SelectionManager.Remove(asset.markerTrack);
                    foreach (var marker in asset.markerTrack.GetMarkers())
                    {
                        SelectionManager.Remove(marker);
                    }
                }
            }
        }
        internal void SetShowMarkerHeader(bool newValue)
        {
            TimelineAsset asset = state.editSequence.asset;

            if (state.showMarkerHeader == newValue || asset == null)
            {
                return;
            }

            string undoOperation = L10n.Tr("Toggle Show Markers");

            if (newValue)
            {
                //Create the marker track if it does not exist
                TimelineUndo.PushUndo(asset, undoOperation);
                asset.CreateMarkerTrack();
            }
            else
            {
                SelectionManager.Remove(asset.markerTrack);
            }

            asset.markerTrack.SetShowTrackMarkers(newValue);
        }
예제 #24
0
 public static void Remove(TimelineClip item)
 {
     SelectionManager.Remove(EditorItemFactory.GetEditorClip(item));
 }
예제 #25
0
 public static void Remove(TimelineMarker item)
 {
     SelectionManager.Remove(EditorItemFactory.GetEditorMarker(item));
 }
예제 #26
0
 public override void Init(IControl parent)
 {
     parent.DoubleClick += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         this.m_DoubleClicked = true;
         bool result;
         if (state.IsEditingASubItem())
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineTrackGUI timelineTrackGUI = target as TimelineTrackGUI;
             if (timelineTrackGUI == null)
             {
                 result = base.IgnoreEvent();
             }
             else if (evt.get_button() != 0)
             {
                 result = base.IgnoreEvent();
             }
             else if (!timelineTrackGUI.indentedHeaderBounds.Contains(evt.get_mousePosition()))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 bool flag = SelectionManager.SelectedTracks().Contains(timelineTrackGUI.track);
                 foreach (TimelineItemGUI current in timelineTrackGUI.items)
                 {
                     if (flag)
                     {
                         SelectionManager.Add(current.item);
                     }
                     else
                     {
                         SelectionManager.Remove(current.item);
                     }
                 }
                 result = base.ConsumeEvent();
             }
         }
         return(result);
     };
     parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         this.m_DoubleClicked = false;
         bool result;
         if (state.IsCurrentEditingASequencerTextField())
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineGroupGUI timelineGroupGUI = target as TimelineGroupGUI;
             if (timelineGroupGUI == null)
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 if (target is TimelineTrackGUI)
                 {
                     TimelineTrackGUI timelineTrackGUI = target as TimelineTrackGUI;
                     if (timelineTrackGUI.locked)
                     {
                         if (SelectorTool.CanClearSelection(evt, timelineGroupGUI))
                         {
                             SelectionManager.Clear();
                         }
                         SelectionManager.Add(timelineTrackGUI.track);
                     }
                     bool flag = timelineTrackGUI.items.Any((TimelineItemGUI x) => x.bounds.Contains(evt.get_mousePosition()));
                     if (flag && !TimelineWindow.instance.sequenceHeaderBounds.Contains(evt.get_mousePosition()))
                     {
                         result = base.IgnoreEvent();
                         return(result);
                     }
                 }
                 if (SelectorTool.CanClearSelection(evt, timelineGroupGUI))
                 {
                     SelectionManager.Clear();
                 }
                 IEnumerable <TrackAsset> source = SelectionManager.SelectedTracks();
                 if (evt.get_modifiers() == 2 || evt.get_modifiers() == 8)
                 {
                     if (SelectionManager.Contains(timelineGroupGUI.track))
                     {
                         SelectionManager.Remove(timelineGroupGUI.track);
                     }
                     else
                     {
                         SelectionManager.Add(timelineGroupGUI.track);
                     }
                 }
                 else if (evt.get_modifiers() == 1)
                 {
                     if (!source.Any <TrackAsset>() && !SelectionManager.Contains(timelineGroupGUI.track))
                     {
                         SelectionManager.Add(timelineGroupGUI.track);
                     }
                     else
                     {
                         bool flag2 = false;
                         foreach (TimelineTrackBaseGUI current in TimelineWindow.instance.allTracks)
                         {
                             if (!flag2)
                             {
                                 if (current == timelineGroupGUI || SelectionManager.Contains(current.track))
                                 {
                                     SelectionManager.Add(current.track);
                                     flag2 = true;
                                     continue;
                                 }
                             }
                             if (flag2)
                             {
                                 if (current == timelineGroupGUI || SelectionManager.Contains(current.track))
                                 {
                                     SelectionManager.Add(current.track);
                                     flag2 = false;
                                     continue;
                                 }
                             }
                             if (flag2)
                             {
                                 SelectionManager.Add(current.track);
                             }
                         }
                     }
                 }
                 else
                 {
                     SelectionManager.Add(timelineGroupGUI.track);
                 }
                 result = base.IgnoreEvent();
             }
         }
         return(result);
     };
     parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (this.m_DoubleClicked || evt.get_modifiers() != null || evt.get_button() != 0 || !SelectionManager.IsMultiSelect())
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineGroupGUI timelineGroupGUI = target as TimelineGroupGUI;
             if (timelineGroupGUI == null)
             {
                 result = base.IgnoreEvent();
             }
             else if (!SelectionManager.Contains(timelineGroupGUI.track))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 SelectionManager.Clear();
                 SelectionManager.Add(timelineGroupGUI.track);
                 result = base.ConsumeEvent();
             }
         }
         return(result);
     };
 }
예제 #27
0
 public override void Deselect()
 {
     SelectionManager.Remove(marker);
 }
 public override void Deselect()
 {
     SelectionManager.Remove(clip);
 }
 public static void Do(TimelineAsset timeline, TrackAsset track)
 {
     SelectionManager.Remove(track);
     TrackModifier.DeleteTrack(timeline, track);
 }