コード例 #1
0
        internal void AddMenuItem(List <MenuActionItem> menuItems)
        {
            var clips = TimelineEditor.selectedClips;

            if (clips == null || clips.Length != 1)
            {
                return;
            }

            var mode = TimelineWindow.instance.currentMode.mode;
            MenuEntryAttribute menuAttribute = GetType().GetCustomAttributes(typeof(MenuEntryAttribute), false).OfType <MenuEntryAttribute>().FirstOrDefault();
            var menuItem = new MenuActionItem()
            {
                category       = menuAttribute.subMenuPath ?? string.Empty,
                entryName      = menuAttribute.name,
                isActiveInMode = this.IsActionActiveInMode(mode),
                priority       = menuAttribute.priority,
                state          = Validate(clips),
                callback       = null
            };

            var subDirectors = TimelineUtility.GetSubTimelines(clips[0], TimelineEditor.inspectedDirector);

            if (subDirectors.Count == 1)
            {
                menuItem.entryName = SingleItemPrefix + DisplayNameHelper.GetDisplayName(subDirectors[0]);
                menuItem.callback  = () =>
                {
                    Execute(clips);
                };
                menuItems.Add(menuItem);
            }
            else
            {
                for (int i = 0; i < subDirectors.Count; i++)
                {
                    var index = i;
                    menuItem.category  = MultiItemPrefix;
                    menuItem.entryName = DisplayNameHelper.GetDisplayName(subDirectors[i]);
                    menuItem.callback  = () =>
                    {
                        ExecuteInternal(subDirectors, index, clips[0]);
                    };
                    menuItems.Add(menuItem);
                }
            }
        }
コード例 #2
0
        protected override void AddMenuItem(WindowState state, TimelineClip[] items, List <MenuActionItem> menuItems)
        {
            if (items == null || items.Length != 1)
            {
                return;
            }

            var mode     = TimelineWindow.instance.currentMode.mode;
            var menuItem = new MenuActionItem()
            {
                category       = category,
                entryName      = GetDisplayName(items),
                shortCut       = string.Empty,
                isChecked      = false,
                isActiveInMode = IsActionActiveInMode(this, mode),
                priority       = priority,
                state          = GetDisplayState(state, items),
                callback       = null
            };

            var subDirectors = TimelineUtility.GetSubTimelines(items[0], state.editSequence.director);

            if (subDirectors.Count == 1)
            {
                menuItem.entryName = SingleItemPrefix + DisplayNameHelper.GetDisplayName(subDirectors[0]);
                menuItem.callback  = () => Execute(state, items);
                menuItems.Add(menuItem);
            }
            else
            {
                for (int i = 0; i < subDirectors.Count; i++)
                {
                    var index = i;
                    menuItem.category  = MultiItemPrefix;
                    menuItem.entryName = DisplayNameHelper.GetDisplayName(subDirectors[i]);
                    menuItem.callback  = () => ExecuteInternal(state, subDirectors, index, items[0]);
                    menuItems.Add(menuItem);
                }
            }
        }