コード例 #1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public ClipEditor()
 {
     supportsSubTimelines = TypeUtility.HasOverrideMethod(GetType(), nameof(GetSubTimelines));
 }
コード例 #2
0
 public static string GetTrackMenuName(System.Type trackType)
 {
     return(L10n.Tr(TypeUtility.GetDisplayName(trackType)));
 }
コード例 #3
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public MarkerEditor()
 {
     supportsDrawOverlay = TypeUtility.HasOverrideMethod(GetType(), nameof(DrawOverlay));
 }
コード例 #4
0
ファイル: TimelineContextMenu.cs プロジェクト: 0geova0/Jam
        static void AddMarkerMenuCommands(List <MenuActionItem> menuItems, ICollection <TrackAsset> tracks, Action <Type, Object> command, bool enabled)
        {
            var markerTypes = TypeUtility.GetBuiltInMarkerTypes().Union(TypeUtility.GetUserMarkerTypes());

            if (tracks != null)
            {
                markerTypes = markerTypes.Where(x => tracks.All(track => (track == null) || TypeUtility.DoesTrackSupportMarkerType(track, x))); // null track indicates marker track to be created
            }
            AddMarkerMenuCommands(menuItems, markerTypes, command, enabled);
        }
コード例 #5
0
ファイル: TimelineContextMenu.cs プロジェクト: 0geova0/Jam
        static void AddMarkerMenuCommands(List <MenuActionItem> menu, IEnumerable <Type> markerTypes, Action <Type, Object> addMarkerCommand, bool enabled)
        {
            int builtInPriority = MenuOrder.AddMarkerItemStart;
            int customPriority  = MenuOrder.AddCustomMarkerItemStart;

            foreach (var markerType in markerTypes)
            {
                var    markerItemType = markerType;
                string category       = TimelineHelpers.GetItemCategoryName(markerItemType);
                menu.Add(
                    new MenuActionItem()
                {
                    category       = category,
                    entryName      = string.Format(Styles.addItemTemplate, TypeUtility.GetDisplayName(markerType)),
                    shortCut       = string.Empty,
                    isActiveInMode = true,
                    isChecked      = false,
                    priority       = TypeUtility.IsBuiltIn(markerType) ? builtInPriority++ : customPriority++,
                    state          = enabled ? MenuActionDisplayState.Visible : MenuActionDisplayState.Disabled,
                    callback       = () => addMarkerCommand(markerItemType, null)
                }
                    );

                foreach (var objectReference in TypeUtility.ObjectReferencesForType(markerType))
                {
                    var isSceneReference = objectReference.isSceneReference;
                    GenericMenu.MenuFunction menuCallback = () =>
                    {
                        var dataType = markerItemType;
                        ObjectSelector.get.Show(null, dataType, null, isSceneReference, null, (obj) => addMarkerCommand(markerItemType, obj), null);
                        ObjectSelector.get.titleContent = EditorGUIUtility.TrTextContent(string.Format(Styles.typeSelectorTemplate, TypeUtility.GetDisplayName(dataType)));
                    };

                    menu.Add(
                        new MenuActionItem()
                    {
                        category       = TimelineHelpers.GetItemCategoryName(markerItemType),
                        entryName      = string.Format(Styles.addItemFromAssetTemplate, TypeUtility.GetDisplayName(markerType), TypeUtility.GetDisplayName(objectReference.type)),
                        shortCut       = string.Empty,
                        isActiveInMode = true,
                        isChecked      = false,
                        priority       = TypeUtility.IsBuiltIn(markerType) ? builtInPriority++ : customPriority++,
                        state          = enabled ? MenuActionDisplayState.Visible : MenuActionDisplayState.Disabled,
                        callback       = menuCallback
                    }
                        );
                }
            }
        }
コード例 #6
0
ファイル: TimelineContextMenu.cs プロジェクト: 0geova0/Jam
        static void AddClipMenuCommands(List <MenuActionItem> menuItems, ICollection <TrackAsset> tracks, double candidateTime)
        {
            if (!tracks.Any())
            {
                return;
            }

            var trackAsset = tracks.First();
            var trackType  = trackAsset.GetType();

            if (tracks.Any(t => t.GetType() != trackType))
            {
                return;
            }

            var enabled           = tracks.All(t => t != null && !t.lockedInHierarchy) && !TimelineWindow.instance.state.editSequence.isReadOnly;
            var assetTypes        = TypeUtility.GetPlayableAssetsHandledByTrack(trackType);
            var visibleAssetTypes = TypeUtility.GetVisiblePlayableAssetsHandledByTrack(trackType);

            // skips the name if there is only a single type
            var commandNameTemplate = assetTypes.Count() == 1 ? Styles.addSingleItemFromAssetTemplate : Styles.addItemFromAssetTemplate;
            int builtInPriority     = MenuOrder.AddClipItemStart;
            int customPriority      = MenuOrder.AddCustomClipItemStart;

            foreach (var assetType in assetTypes)
            {
                var             assetItemType   = assetType;
                var             category        = TimelineHelpers.GetItemCategoryName(assetType);
                Action <Object> onObjectChanged = obj =>
                {
                    if (obj != null)
                    {
                        foreach (var t in tracks)
                        {
                            TimelineHelpers.CreateClipOnTrack(assetItemType, obj, t, candidateTime);
                        }
                    }
                };

                foreach (var objectReference in TypeUtility.ObjectReferencesForType(assetType))
                {
                    var isSceneReference = objectReference.isSceneReference;
                    var dataType         = objectReference.type;
                    GenericMenu.MenuFunction menuCallback = () =>
                    {
                        ObjectSelector.get.Show(null, dataType, null, isSceneReference, null, (obj) => onObjectChanged(obj), null);
                        ObjectSelector.get.titleContent = EditorGUIUtility.TrTextContent(string.Format(Styles.typeSelectorTemplate, TypeUtility.GetDisplayName(dataType)));
                    };

                    menuItems.Add(
                        new MenuActionItem()
                    {
                        category       = category,
                        entryName      = string.Format(commandNameTemplate, TypeUtility.GetDisplayName(assetType), TypeUtility.GetDisplayName(objectReference.type)),
                        shortCut       = string.Empty,
                        isActiveInMode = true,
                        isChecked      = false,
                        priority       = TypeUtility.IsBuiltIn(assetType) ? builtInPriority++ : customPriority++,
                        state          = enabled ? MenuActionDisplayState.Visible : MenuActionDisplayState.Disabled,
                        callback       = menuCallback
                    }
                        );
                }
            }

            foreach (var assetType in visibleAssetTypes)
            {
                var assetItemType = assetType;
                var category      = TimelineHelpers.GetItemCategoryName(assetType);
                var commandName   = string.Format(Styles.addItemTemplate, TypeUtility.GetDisplayName(assetType));
                GenericMenu.MenuFunction command = () =>
                {
                    foreach (var t in tracks)
                    {
                        TimelineHelpers.CreateClipOnTrack(assetItemType, t, candidateTime);
                    }
                };

                menuItems.Add(
                    new MenuActionItem()
                {
                    category       = category,
                    entryName      = commandName,
                    shortCut       = string.Empty,
                    isActiveInMode = true,
                    isChecked      = false,
                    priority       = TypeUtility.IsBuiltIn(assetItemType) ? builtInPriority++ : customPriority++,
                    state          = enabled ? MenuActionDisplayState.Visible : MenuActionDisplayState.Disabled,
                    callback       = command
                }
                    );
            }
        }
コード例 #7
0
ファイル: TimelineContextMenu.cs プロジェクト: 0geova0/Jam
        internal static void BuildNewTracksContextMenu(List <MenuActionItem> menuItems, ICollection <TrackAsset> parentTracks, WindowState state, string format = null)
        {
            if (parentTracks == null)
            {
                parentTracks = new TrackAsset[0];
            }

            if (string.IsNullOrEmpty(format))
            {
                format = "{0}";
            }

            // Add Group or SubGroup
            var title     = string.Format(format, parentTracks.Any(t => t != null) ? Styles.trackSubGroup : Styles.trackGroup);
            var menuState = MenuActionDisplayState.Visible;

            if (state.editSequence.isReadOnly)
            {
                menuState = MenuActionDisplayState.Disabled;
            }
            if (parentTracks.Any() && parentTracks.Any(t => t != null && t.lockedInHierarchy))
            {
                menuState = MenuActionDisplayState.Disabled;
            }

            GenericMenu.MenuFunction command = () =>
            {
                SelectionManager.Clear();
                if (parentTracks.Count == 0)
                {
                    Selection.Add(TimelineHelpers.CreateTrack <GroupTrack>(null, title));
                }

                foreach (var parentTrack in parentTracks)
                {
                    Selection.Add(TimelineHelpers.CreateTrack <GroupTrack>(parentTrack, title));
                }

                TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
            };

            menuItems.Add(
                new MenuActionItem()
            {
                category       = string.Empty,
                entryName      = title,
                shortCut       = string.Empty,
                isActiveInMode = true,
                isChecked      = false,
                priority       = MenuOrder.AddGroupItemStart,
                state          = menuState,
                callback       = command
            }
                );


            var allTypes = TypeUtility.AllTrackTypes().Where(x => x != typeof(GroupTrack) && !TypeUtility.IsHiddenInMenu(x)).ToList();

            int builtInPriority = MenuOrder.AddTrackItemStart;
            int customPriority  = MenuOrder.AddCustomTrackItemStart;

            foreach (var trackType in allTypes)
            {
                var trackItemType = trackType;

                command = () =>
                {
                    SelectionManager.Clear();

                    if (parentTracks.Count == 0)
                    {
                        SelectionManager.Add(TimelineHelpers.CreateTrack((Type)trackItemType, null));
                    }

                    foreach (var parentTrack in parentTracks)
                    {
                        SelectionManager.Add(TimelineHelpers.CreateTrack((Type)trackItemType, parentTrack));
                    }
                };

                menuItems.Add(
                    new MenuActionItem()
                {
                    category       = TimelineHelpers.GetTrackCategoryName(trackType),
                    entryName      = string.Format(format, TimelineHelpers.GetTrackMenuName(trackItemType)),
                    shortCut       = string.Empty,
                    isActiveInMode = true,
                    isChecked      = false,
                    priority       = TypeUtility.IsBuiltIn(trackType) ? builtInPriority++ : customPriority++,
                    state          = menuState,
                    callback       = command
                }
                    );
            }
        }
コード例 #8
0
 public static bool SupportsBindingAssign(this TrackEditor editor)
 {
     return(TypeUtility.HasOverrideMethod(editor.GetType(), nameof(TrackEditor.GetBindingFrom)));
 }