コード例 #1
0
        private void ShowConditionElementContextMenu(RSConditionData inConditionData, int inIndex)
        {
            GenericMenu menu = new GenericMenu();

            menu.AddItem(s_ContextMenuCopyLabel, false, () => RSEditorClipboard.CopyCondition(inConditionData));
            if (RSEditorClipboard.HasCondition())
            {
                menu.AddItem(s_ContextMenuPasteOverwriteLabel, false, () =>
                {
                    m_TargetState.UndoTarget.MarkDirty("Paste condition (overwrite)");
                    RSEditorClipboard.PasteCondition(inConditionData);
                });
                if (EditorApplication.isPlaying)
                {
                    menu.AddDisabledItem(s_ContextMenuPasteInsertLabel, false);
                }
                else
                {
                    menu.AddItem(s_ContextMenuPasteInsertLabel, false, () =>
                    {
                        RSConditionData clone = RSEditorClipboard.PasteCondition();
                        InsertCondition(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, () => DeleteCondition(inIndex));
            }

            menu.ShowAsContext();
        }
コード例 #2
0
        private void ShowConditionHeaderContextMenu()
        {
            GenericMenu menu = new GenericMenu();

            if (EditorApplication.isPlaying)
            {
                menu.AddDisabledItem(s_ContextMenuPasteAddToEndLabel, false);
                menu.AddDisabledItem(s_ContextMenuDeleteAllLabel, false);
            }
            else
            {
                if (RSEditorClipboard.HasCondition())
                {
                    menu.AddItem(s_ContextMenuPasteAddToEndLabel, false, () =>
                    {
                        RSConditionData clone = RSEditorClipboard.PasteCondition();
                        InsertCondition(clone, -1);
                    });
                }
                else
                {
                    menu.AddDisabledItem(s_ContextMenuPasteAddToEndLabel, false);
                }

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

            menu.ShowAsContext();
        }