예제 #1
0
        protected override bool ContextClick(Event evt, WindowState state)
        {
            if (!m_TimeAreaItem.bounds.Contains(evt.mousePosition))
            {
                return(false);
            }

            var tolerance = 0.25f / state.referenceSequence.frameRate;
            var menu      = new GenericMenu();

            if (!TimelineWindow.instance.state.editSequence.isReadOnly)
            {
                menu.AddItem(EditorGUIUtility.TrTextContent("Insert/Frame/Single"), false, () =>
                {
                    Gaps.Insert(state.editSequence.asset, state.editSequence.time, 1.0f / state.referenceSequence.frameRate, tolerance);
                    state.Refresh();
                }
                             );

                int[] values = { 5, 10, 25, 100 };

                for (var i = 0; i != values.Length; ++i)
                {
                    float f = values[i];
                    menu.AddItem(EditorGUIUtility.TrTextContent("Insert/Frame/" + values[i] + " Frames"), false, () =>
                    {
                        Gaps.Insert(state.editSequence.asset, state.editSequence.time, f / state.referenceSequence.frameRate, tolerance);
                        state.Refresh();
                    }
                                 );
                }

                var playRangeTime = state.playRange;
                if (playRangeTime.y > playRangeTime.x)
                {
                    menu.AddItem(EditorGUIUtility.TrTextContent("Insert/Selected Time"), false, () =>
                    {
                        Gaps.Insert(state.editSequence.asset, playRangeTime.x, playRangeTime.y - playRangeTime.x, tolerance);
                        state.Refresh();
                    }
                                 );
                }
            }

            menu.AddItem(EditorGUIUtility.TrTextContent("Select/Clips Ending Before"), false, () => SelectMenuCallback(x => x.end < state.editSequence.time + tolerance, state));
            menu.AddItem(EditorGUIUtility.TrTextContent("Select/Clips Starting Before"), false, () => SelectMenuCallback(x => x.start < state.editSequence.time + tolerance, state));
            menu.AddItem(EditorGUIUtility.TrTextContent("Select/Clips Ending After"), false, () => SelectMenuCallback(x => x.end - state.editSequence.time >= -tolerance, state));
            menu.AddItem(EditorGUIUtility.TrTextContent("Select/Clips Starting After"), false, () => SelectMenuCallback(x => x.start - state.editSequence.time >= -tolerance, state));
            menu.AddItem(EditorGUIUtility.TrTextContent("Select/Clips Intersecting"), false, () => SelectMenuCallback(x => x.start <= state.editSequence.time && state.editSequence.time <= x.end, state));
            menu.AddItem(EditorGUIUtility.TrTextContent("Select/Blends Intersecting"), false, () => SelectMenuCallback(x => SelectBlendingIntersecting(x, state.editSequence.time), state));
            menu.ShowAsContext();
            return(true);
        }
예제 #2
0
        public override bool Execute(WindowState state, TrackAsset[] tracks)
        {
            if (tracks.Any())
            {
                SelectionManager.RemoveTimelineSelection();
            }

            foreach (var track in TrackExtensions.FilterTracks(tracks))
            {
                var newTrack = track.Duplicate(TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector);
                SelectionManager.Add(newTrack);
                foreach (var childTrack in newTrack.GetFlattenedChildTracks())
                {
                    SelectionManager.Add(childTrack);
                }

                if (TimelineEditor.inspectedDirector != null)
                {
                    var binding = TimelineEditor.inspectedDirector.GetGenericBinding(track);
                    if (binding != null)
                    {
                        TimelineUndo.PushUndo(TimelineEditor.inspectedDirector, "Duplicate");
                        TimelineEditor.inspectedDirector.SetGenericBinding(newTrack, binding);
                    }
                }
            }

            state.Refresh();

            return(true);
        }
        void DrawRemoveMenu(Rect headerRect, WindowState state)
        {
            const float pad        = 3;
            const float buttonSize = 16;
            var         buttonRect = new Rect(headerRect.xMax - buttonSize - pad, headerRect.y + ((headerRect.height - buttonSize) / 2f) + 2, buttonSize, buttonSize);

            if (GUI.Button(buttonRect, GUIContent.none, DirectorStyles.Instance.trackOptions))
            {
                GenericMenu menu = new GenericMenu();

                var owner            = m_Owner;
                var scriptableObject = m_ScriptableObject;

                menu.AddItem(Styles.RemoveTrack, false, () =>
                {
                    if (TrackExtensions.RemoveBrokenTrack(owner, scriptableObject))
                    {
                        state.Refresh();
                    }
                }
                             );

                menu.ShowAsContext();
            }
        }
        public static bool HandleShortcut(WindowState state, Event evt, T item)
        {
            T[] items = { item };

            foreach (ItemAction <T> action in actions)
            {
                var attr = action.GetType().GetCustomAttributes(typeof(ShortcutAttribute), true);

                foreach (ShortcutAttribute shortcut in attr)
                {
                    if (shortcut.MatchesEvent(evt))
                    {
                        if (s_ShowActionTriggeredByShortcut)
                        {
                            Debug.Log(action.GetType().Name);
                        }

                        if (!IsActionActiveInMode(action, TimelineWindow.instance.currentMode.mode))
                        {
                            return(false);
                        }

                        var result = action.Execute(state, items);
                        state.Refresh();
                        state.Evaluate();
                        return(result);
                    }
                }
            }

            return(false);
        }
        public override bool Execute(WindowState state)
        {
            if (SelectionManager.GetCurrentInlineEditorCurve() != null)
            {
                return(false);
            }

            if (!CanDelete(state))
            {
                return(false);
            }

            var selectedItems = SelectionManager.SelectedItems();

            DeleteItems(selectedItems);

            var tracks = SelectionManager.SelectedTracks().ToArray();

            if (tracks.Any())
            {
                TrackAction.Invoke <DeleteTracks>(state, tracks);
            }

            state.Refresh();
            return(selectedItems.Any() || tracks.Length > 0);
        }
        internal bool Execute(WindowState state, Func <ITimelineItem, ITimelineItem, double> gapBetweenItems)
        {
            var selectedItems = SelectionManager.SelectedItems().ToItemsPerTrack().ToList();

            if (selectedItems.Any())
            {
                var requestedTime   = CalculateDuplicateTime(selectedItems, gapBetweenItems);
                var duplicatedItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(state, TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, selectedItems, requestedTime, "Duplicate Items");

                TimelineHelpers.FrameItems(state, duplicatedItems);
                SelectionManager.RemoveTimelineSelection();
                foreach (var item in duplicatedItems)
                {
                    SelectionManager.Add(item);
                }
            }

            var tracks = SelectionManager.SelectedTracks().ToArray();

            if (tracks.Length > 0)
            {
                TrackAction.Invoke <DuplicateTracks>(state, tracks);
            }

            state.Refresh();
            return(true);
        }
예제 #7
0
        public static bool CollapseGroup(WindowState state)
        {
            if (TrackHeadActive())
            {
                var quit = false;
                foreach (var track in SelectionManager.SelectedTracks())
                {
                    if (!track.GetChildTracks().Any())
                    {
                        continue;
                    }
                    if (!quit && !track.GetCollapsed())
                    {
                        quit = true;
                    }
                    track.SetCollapsed(true);
                }
                if (quit)
                {
                    state.Refresh();
                    return(true);
                }

                var selectedTrack = SelectionManager.SelectedTracks().LastOrDefault();
                var parent        = selectedTrack != null ? selectedTrack.parent as TrackAsset : null;
                if (parent)
                {
                    SelectionManager.SelectOnly(parent);
                    FrameTrackHeader(GetVisibleTracks().First(x => x.track == parent));
                    return(true);
                }
            }
            return(false);
        }
        static void AddSubTrack(WindowState state, Type trackOfType, string trackName, TrackAsset track)
        {
            var subAnimationTrack = state.editSequence.asset.CreateTrack(trackOfType, track, trackName);

            TimelineCreateUtilities.SaveAssetIntoObject(subAnimationTrack, track);
            track.SetCollapsed(false);
            state.Refresh();
        }
        public static void KeyProperties(GameObject go, WindowState state, IList <EditorCurveBinding> bindings)
        {
            var allKeyedProperties = new List <PropertyModification>();
            var rotationPaths      = new HashSet <string>();

            for (var i = 0; i < bindings.Count; ++i)
            {
                // Skip the euler and key quaternion+hint
                if (CurveEditUtility.IsRotationKey(bindings[i]))
                {
                    rotationPaths.Add(bindings[i].path);
                    continue;
                }

                AnimationUtility.GetFloatValue(go, bindings[i], out var val);
                var compo = GetTargetFromEditorBinding(go, bindings[i]);
                allKeyedProperties.Add(new PropertyModification
                {
                    target       = compo,
                    value        = val.ToString(EditorGUI.kFloatFieldFormatString),
                    propertyPath = bindings[i].propertyName
                });
            }

            foreach (var path in rotationPaths)
            {
                foreach (var binding in GetRotationBindings(path))
                {
                    var compo       = GetTargetFromEditorBinding(go, binding);
                    var readBinding = binding;
                    switch (binding.propertyName)
                    {
                    case kLocalEulerHint + ".x":
                        readBinding = EditorCurveBinding.FloatCurve(path, typeof(Transform), kLocalRotation + ".x");
                        break;

                    case kLocalEulerHint + ".y":
                        readBinding = EditorCurveBinding.FloatCurve(path, typeof(Transform), kLocalRotation + ".y");
                        break;

                    case kLocalEulerHint + ".z":
                        readBinding = EditorCurveBinding.FloatCurve(path, typeof(Transform), kLocalRotation + ".z");
                        break;
                    }

                    AnimationUtility.GetFloatValue(go, readBinding, out var val);
                    allKeyedProperties.Add(new PropertyModification
                    {
                        target       = compo,
                        value        = val.ToString(EditorGUI.kFloatFieldFormatString),
                        propertyPath = binding.propertyName
                    });
                }
            }

            AddKey(allKeyedProperties, state);
            state.Refresh();
        }
예제 #10
0
        public override bool Execute(WindowState state, TimelineClip[] clips)
        {
            bool success = ClipModifier.Split(clips, state.editSequence.time, state.editSequence.director);

            if (success)
            {
                state.Refresh();
            }
            return(success);
        }
예제 #11
0
        /// <summary>
        /// Shared code for adding a clip to a track
        /// </summary>
        static void AddClipOnTrack(TimelineClip newClip, TrackAsset parentTrack, double candidateTime, Object assignableObject, WindowState state)
        {
            var playableAsset = newClip.asset as IPlayableAsset;

            newClip.parentTrack = null;
            newClip.timeScale   = 1.0;
            newClip.mixInCurve  = AnimationCurve.EaseInOut(0, 0, 1, 1);
            newClip.mixOutCurve = AnimationCurve.EaseInOut(0, 1, 1, 0);

            var playableDirector = state != null ? state.editSequence.director : null;

            if (assignableObject != null)
            {
                foreach (var field in ObjectReferenceField.FindObjectReferences(playableAsset.GetType()))
                {
                    if (field.IsAssignable(assignableObject))
                    {
                        newClip.displayName = assignableObject.name;
                        field.Assign(newClip.asset as PlayableAsset, assignableObject, playableDirector);
                        break;
                    }
                }
            }

            // get the clip editor
            try
            {
                CustomTimelineEditorCache.GetClipEditor(newClip).OnCreate(newClip, parentTrack, null);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }


            // reset the duration as the newly assigned values may have changed the default
            if (playableAsset != null)
            {
                var candidateDuration = playableAsset.duration;

                if (!double.IsInfinity(candidateDuration) && candidateDuration > 0)
                {
                    newClip.duration = Math.Min(Math.Max(candidateDuration, TimelineClip.kMinDuration), TimelineClip.kMaxTimeValue);
                }
            }

            var newClipsByTracks = new[] { new ItemsPerTrack(parentTrack, new[] { newClip.ToItem() }) };

            FinalizeInsertItemsUsingCurrentEditMode(state, newClipsByTracks, candidateTime);

            if (state != null)
            {
                state.Refresh();
            }
        }
        public override bool Execute(WindowState state, TrackAsset[] tracks)
        {
            foreach (var track in tracks)
            {
                TimelineHelpers.CreateTrack <GroupTrack>(track, "Track Sub-Group");
            }

            state.Refresh();

            return(true);
        }
예제 #13
0
        static void ShowHide(WindowState state, TrackAsset[] tracks, bool shouldLock)
        {
            if (tracks.Length == 0)
            {
                return;
            }

            foreach (var track in tracks)
            {
                track.SetShowMarkers(shouldLock);
            }

            state.Refresh();
        }
        public static void Mute(WindowState state, TrackAsset[] tracks, bool shouldMute)
        {
            if (tracks.Length == 0)
            {
                return;
            }

            foreach (var track in tracks.Where(t => !TimelineUtility.IsParentMuted(t)))
            {
                TimelineUndo.PushUndo(track, "Mute Tracks");
                track.muted = shouldMute;
            }
            state.Refresh();
        }
        float DrawMuteButton(Rect rect, WindowState state)
        {
            if (track.muted)
            {
                if (GUI.Button(rect, GUIContent.none, TimelineWindow.styles.mute))
                {
                    track.muted = false;
                    state.Refresh();
                }
                return(WindowConstants.trackHeaderButtonSize);
            }

            return(0.0f);
        }
예제 #16
0
        public static bool UnCollapseGroup(WindowState state)
        {
            if (TrackHeadActive())
            {
                var quit = false;
                foreach (var track in SelectionManager.SelectedTracks())
                {
                    if (!track.GetChildTracks().Any())
                    {
                        continue;
                    }

                    if (!quit && track.GetCollapsed())
                    {
                        quit = true;
                    }
                    track.SetCollapsed(false);
                }

                if (quit)
                {
                    state.Refresh();
                    return(true);
                }

                // Transition to Clip area
                var           visibleTracks = GetVisibleTracks().Select(x => x.track).ToList();
                var           idx           = visibleTracks.IndexOf(SelectionManager.SelectedTracks().Last());
                ITimelineItem item          = null;
                for (var i = idx; i < visibleTracks.Count; ++i)
                {
                    var items = visibleTracks[i].GetItems().OfType <ClipItem>();
                    if (!items.Any())
                    {
                        continue;
                    }
                    item = items.First();
                    break;
                }

                if (item != null)
                {
                    SelectionManager.SelectOnly(item);
                    TimelineHelpers.FrameItems(state, new[] { item });
                    return(true);
                }
            }
            return(false);
        }
        public override bool Execute(WindowState state)
        {
            if (!CanPaste(state))
            {
                return(false);
            }

            PasteItems(state, m_MousePosition);
            PasteTracks(state);

            state.Refresh();

            ClearMousePosition();
            return(true);
        }
예제 #18
0
        static void Mute(WindowState state, TrackAsset[] tracks, bool shouldMute)
        {
            if (tracks.Length == 0)
            {
                return;
            }

            foreach (var track in tracks)
            {
                TimelineUndo.PushUndo(track, "Mute Tracks");
                track.muted = shouldMute;
            }

            state.Refresh();
        }
예제 #19
0
        void UpdateDrawData(WindowState state)
        {
            if (Event.current.type == EventType.Layout)
            {
                m_TrackDrawData.m_ShowTrackBindings = false;
                m_TrackDrawData.m_TrackBinding      = null;


                if (state.editSequence.director != null && showSceneReference)
                {
                    m_TrackDrawData.m_ShowTrackBindings = state.GetWindow().currentMode.ShouldShowTrackBindings(state);
                    m_TrackDrawData.m_TrackBinding      = state.editSequence.director.GetGenericBinding(track);
                }

                var lastError  = m_TrackDrawOptions.errorText;
                var lastHeight = m_TrackDrawOptions.minimumHeight;
                try
                {
                    m_TrackDrawOptions = m_TrackEditor.GetTrackOptions(track, m_TrackDrawData.m_TrackBinding);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                    m_TrackDrawOptions = CustomTimelineEditorCache.GetDefaultTrackEditor().GetTrackOptions(track, m_TrackDrawData.m_TrackBinding);
                }

                m_TrackDrawData.m_AllowsRecording = DoesTrackAllowsRecording(track);
                m_TrackDrawData.m_TrackIcon       = m_TrackDrawOptions.icon;
                if (m_TrackDrawData.m_TrackIcon == null)
                {
                    m_TrackDrawData.m_TrackIcon = m_DefaultTrackIcon.image;
                }
                // if the problem state has changed, it may be due to external bindings
                // in that case, we need to tell the graph to rebuild.
                // there is no notification from the engine for some markers that invalidate the graph (addcomponent)
                if (m_TrackDrawData.m_ShowTrackBindings && lastError != null && !lastError.Equals(m_TrackDrawOptions.errorText) && !state.playing)
                {
                    state.rebuildGraph = true;
                }

                // track height has changed. need to update gui
                if (!Mathf.Approximately(lastHeight, m_TrackDrawOptions.minimumHeight))
                {
                    state.Refresh();
                }
            }
        }
        public override bool Execute(WindowState state, TrackAsset[] tracks)
        {
            // disable preview mode so deleted tracks revert to default state
            // Case 956129: Disable preview mode _before_ deleting the tracks, since clip data is still needed
            state.previewMode = false;

            TimelineAnimationUtilities.UnlinkAnimationWindowFromTracks(tracks);

            foreach (var track in tracks)
            {
                Do(state.editSequence.asset, track);
            }

            state.Refresh();

            return(true);
        }
예제 #21
0
        public override bool Execute(WindowState state, TrackAsset[] tracks)
        {
            foreach (var track in tracks)
            {
                state.editSequence.asset.CreateTrack <GroupTrack>(track, "Track Sub-Group");

                var uiTrack = TimelineTrackBaseGUI.FindGUITrack(track);

                if (uiTrack != null)
                {
                    TimelineWindow.instance.treeView.data.SetExpanded(uiTrack, true);
                }
            }

            state.Refresh();

            return(true);
        }
예제 #22
0
        // Given an appropriate parent track, create a recordable clip
        public static TimelineClip AddRecordableClip(TrackAsset parentTrack, WindowState state, double atTime)
        {
            var sequenceAsset = state.editSequence.asset;

            if (sequenceAsset == null)
            {
                Debug.LogError("Parent Track needs to be bound to an asset to add a recordable");
                return(null);
            }

            var animTrack = parentTrack as AnimationTrack;

            if (animTrack == null)
            {
                Debug.LogError("Recordable clips are only valid on Animation Tracks");
                return(null);
            }

            var newClip = animTrack.CreateRecordableClip(GetUniqueRecordedClipName(parentTrack, kRecordClipDefaultName));

            if (newClip == null)
            {
                Debug.LogError("Could not create a recordable clip");
                return(null);
            }

            newClip.mixInCurve  = AnimationCurve.EaseInOut(0, 0, 1, 1);
            newClip.mixOutCurve = AnimationCurve.EaseInOut(0, 1, 1, 0);

            newClip.preExtrapolationMode  = TimelineClip.ClipExtrapolation.Hold;
            newClip.postExtrapolationMode = TimelineClip.ClipExtrapolation.Hold;

            double startTime = 0;
            double endTime   = 0;

            GetAddedRecordingClipRange(animTrack, state, atTime, out startTime, out endTime);

            newClip.start    = startTime;
            newClip.duration = endTime - startTime;

            state.Refresh();

            return(newClip);
        }
        public static void Mute(WindowState state, TrackAsset[] tracks, bool shouldMute)
        {
            if (tracks.Length == 0)
            {
                return;
            }

            foreach (var track in tracks)
            {
                if (track as GroupTrack == null)
                {
                    Mute(state, track.GetChildTracks().ToArray(), shouldMute);
                }
                TimelineUndo.PushUndo(track, "Mute Tracks");
                track.muted = shouldMute;
            }

            state.Refresh();
        }
        float DrawLockMarkersButton(Rect rect, WindowState state)
        {
            if (track.GetMarkerCount() == 0)
            {
                return(0.0f);
            }

            var style = TimelineWindow.styles.collapseMarkers;

            if (Event.current.type == EventType.Repaint)
            {
                style.Draw(rect, GUIContent.none, false, false, showMarkers, false);
            }
            if (GUI.Button(rect, DirectorStyles.markerCollapseButton, GUIStyle.none))
            {
                track.SetShowMarkers(!track.GetShowMarkers());
                state.Refresh();
            }
            return(WindowConstants.trackHeaderButtonSize);
        }
        void Done()
        {
            foreach (var movingItem in movingItems)
            {
                foreach (var item in movingItem.items)
                {
                    if (item.gui != null)
                    {
                        item.gui.isInvalid = false;
                    }
                }
            }

            movingItems            = null;
            m_LeftMostMovingItems  = null;
            m_RightMostMovingItems = null;
            m_Grabbing             = false;

            m_State.Refresh();
        }
        public override bool Execute(WindowState state, TrackAsset[] tracks)
        {
            if (tracks.Any())
            {
                SelectionManager.RemoveTimelineSelection();
            }

            foreach (var track in TrackExtensions.FilterTracks(tracks))
            {
                var newTrack = track.Duplicate(TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector);
                SelectionManager.Add(newTrack);
                foreach (var childTrack in newTrack.GetFlattenedChildTracks())
                {
                    SelectionManager.Add(childTrack);
                }
            }

            state.Refresh();

            return(true);
        }
        void Done()
        {
            foreach (var movingItem in movingItems)
            {
                foreach (var item in movingItem.items)
                {
                    if (item.gui != null)
                    {
                        item.gui.isInvalid = false;
                    }
                }
            }

            movingItems            = null;
            m_LeftMostMovingItems  = null;
            m_RightMostMovingItems = null;
            m_Grabbing             = false;

            m_State.Refresh();
            m_State.analytics.SendManipulationEndedEvent();
        }
예제 #28
0
        void UpdateDrawData(WindowState state)
        {
            if (Event.current.type == EventType.Layout)
            {
                m_TrackDrawData.m_ShowTrackBindings = false;
                m_TrackDrawData.m_TrackBinding      = null;


                if (state.editSequence.director != null && showSceneReference)
                {
                    m_TrackDrawData.m_ShowTrackBindings = state.GetWindow().currentMode.ShouldShowTrackBindings(state);
                    m_TrackDrawData.m_TrackBinding      = state.editSequence.director.GetGenericBinding(track);
                }

                var lastError  = m_TrackDrawOptions.errorText;
                var lastHeight = m_TrackDrawOptions.minimumHeight;
                try
                {
                    m_TrackDrawOptions = m_TrackEditor.GetTrackOptions(track, m_TrackDrawData.m_TrackBinding);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                    m_TrackDrawOptions = CustomTimelineEditorCache.GetDefaultTrackEditor().GetTrackOptions(track, m_TrackDrawData.m_TrackBinding);
                }

                m_TrackDrawData.m_AllowsRecording = DoesTrackAllowsRecording(track);
                m_TrackDrawData.m_TrackIcon       = m_TrackDrawOptions.icon;
                if (m_TrackDrawData.m_TrackIcon == null)
                {
                    m_TrackDrawData.m_TrackIcon = m_DefaultTrackIcon.image;
                }

                // track height has changed. need to update gui
                if (!Mathf.Approximately(lastHeight, m_TrackDrawOptions.minimumHeight))
                {
                    state.Refresh();
                }
            }
        }
예제 #29
0
        static void AddTrackMenuCommands(GenericMenu newTrackMenu, TrackAsset parentTrack, TimelineGroupGUI parentGroup, WindowState state)
        {
            // Add Group or SubGroup
            var title = parentTrack == null?L10n.Tr("Track Group") : L10n.Tr("Track Sub-Group");

            var disabled = parentTrack != null && parentTrack.lockedInHierarchy;

            GenericMenu.MenuFunction command = () =>
            {
                SelectionManager.Clear();
                TimelineGroupGUI.Create(parentTrack, title);
                state.Refresh();
            };

            AddCommandToMenu(newTrackMenu, title, command, !disabled);
            newTrackMenu.AddSeparator("");

            var allTypes    = TypeUtility.AllTrackTypes().Where(x => x != typeof(GroupTrack) && !TypeUtility.IsHiddenInMenu(x) && x.IsPublic).ToList();
            var builtIn     = allTypes.Where(x => x.Assembly.Equals(typeof(TimelineAsset).Assembly)).OrderBy(i => i.FullName).ToList();
            var customTypes = allTypes.Except(builtIn).ToList();

            foreach (var t in builtIn)
            {
                AddNewTrackMenuCommand(newTrackMenu, parentTrack, parentGroup, t, state);
            }

            if (builtIn.Any() && customTypes.Any())
            {
                newTrackMenu.AddSeparator("");
            }

            foreach (var t in customTypes)
            {
                AddNewTrackMenuCommand(newTrackMenu, parentTrack, parentGroup, t, state);
            }
        }
예제 #30
0
        static void AddNewTrackMenuCommand(GenericMenu menu, TrackAsset parentTrack, TimelineGroupGUI parentGroup, Type type, WindowState state)
        {
            GenericMenu.MenuFunction2 lastMethod = trackType =>
            {
                SelectionManager.Clear();

                if (parentTrack is GroupTrack)
                {
                    parentTrack.SetCollapsed(false);
                }
                var track = state.GetWindow().AddTrack((Type)trackType, parentGroup == null ? null : parentGroup.track);
                if (parentGroup != null)
                {
                    state.GetWindow().treeView.data.SetExpanded(parentGroup, true);
                }

                if (track.GetType() == typeof(ActivationTrack))
                {
                    var clip = track.CreateClip(0);
                    clip.displayName = ActivationTrackDrawer.Styles.ClipText.text;
                    state.Refresh();
                }
            };

            var category = TimelineHelpers.GetTrackCategoryName(type);

            if (!string.IsNullOrEmpty(category))
            {
                category += "/";
            }

            var name     = category + TimelineHelpers.GetTrackMenuName(type);
            var disabled = parentTrack != null && parentTrack.lockedInHierarchy;

            AddCommandToMenu(menu, name, lastMethod, type, !disabled);
        }