Пример #1
0
        private void ShowActionElementContextMenu(RSActionData inActionData, int inIndex)
        {
            GenericMenu menu = new GenericMenu();

            menu.AddItem(s_ContextMenuCopyLabel, false, () => RSEditorClipboard.CopyAction(inActionData));
            if (RSEditorClipboard.HasAction())
            {
                menu.AddItem(s_ContextMenuPasteOverwriteLabel, false, () =>
                {
                    m_TargetState.UndoTarget.MarkDirty("Paste action (overwrite)");
                    RSEditorClipboard.PasteAction(inActionData);
                });
                if (EditorApplication.isPlaying)
                {
                    menu.AddDisabledItem(s_ContextMenuPasteInsertLabel, false);
                }
                else
                {
                    menu.AddItem(s_ContextMenuPasteInsertLabel, false, () =>
                    {
                        RSActionData clone = RSEditorClipboard.PasteAction();
                        InsertAction(clone, inIndex + 1);
                    });
                }
            }
            else
            {
                menu.AddDisabledItem(s_ContextMenuPasteOverwriteLabel, false);
                menu.AddDisabledItem(s_ContextMenuPasteInsertLabel, false);
            }

            if (EditorApplication.isPlaying)
            {
                menu.AddDisabledItem(s_ContextMenuDeleteLabel, false);
            }
            else
            {
                menu.AddItem(s_ContextMenuDeleteLabel, false, () => DeleteAction(inIndex));
            }

            menu.ShowAsContext();
        }
Пример #2
0
        private void ShowActionHeaderContextMenu()
        {
            GenericMenu menu = new GenericMenu();

            if (EditorApplication.isPlaying)
            {
                menu.AddDisabledItem(s_ContextMenuPasteAddToEndLabel, false);
                menu.AddDisabledItem(s_ContextMenuDeleteAllLabel, false);
            }
            else
            {
                if (RSEditorClipboard.HasAction())
                {
                    menu.AddItem(s_ContextMenuPasteAddToEndLabel, false, () =>
                    {
                        RSActionData clone = RSEditorClipboard.PasteAction();
                        InsertAction(clone, -1);
                    });
                }
                else
                {
                    menu.AddDisabledItem(s_ContextMenuPasteAddToEndLabel, false);
                }

                if (m_SelectionState.Rule.Actions.Length > 0)
                {
                    menu.AddItem(s_ContextMenuDeleteAllLabel, false, () =>
                    {
                        SelectAction(-1);
                        m_TargetState.UndoTarget.MarkDirty("Removed all Actions", true);
                        m_SelectionState.Rule.Actions = new RSActionData[0];
                    });
                }
                else
                {
                    menu.AddDisabledItem(s_ContextMenuDeleteAllLabel, false);
                }
            }

            menu.ShowAsContext();
        }