private void ShowRuleElementContextMenu(RSRuleData inRuleData, int inIndex) { GenericMenu menu = new GenericMenu(); menu.AddItem(s_ContextMenuCopyLabel, false, () => RSEditorClipboard.CopyRule(inRuleData)); if (RSEditorClipboard.HasRule()) { menu.AddItem(s_ContextMenuPasteOverwriteLabel, false, () => { m_TargetState.UndoTarget.MarkDirty("Paste rule (overwrite)"); RSEditorClipboard.PasteRule(inRuleData); }); if (EditorApplication.isPlaying) { menu.AddDisabledItem(s_ContextMenuPasteInsertLabel, false); } else { menu.AddItem(s_ContextMenuPasteInsertLabel, false, () => { RSRuleData clone = RSEditorClipboard.PasteRule(); InsertRule(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, () => DeleteRule(inIndex)); } menu.ShowAsContext(); }
private void ShowRuleHeaderContextMenu() { GenericMenu menu = new GenericMenu(); if (EditorApplication.isPlaying) { menu.AddDisabledItem(s_ContextMenuPasteAddToEndLabel, false); menu.AddDisabledItem(s_ContextMenuDeleteAllLabel, false); } else { if (RSEditorClipboard.HasRule()) { menu.AddItem(s_ContextMenuPasteAddToEndLabel, false, () => { RSRuleData clone = RSEditorClipboard.PasteRule(); InsertRule(clone, -1); }); } else { menu.AddDisabledItem(s_ContextMenuPasteAddToEndLabel, false); } if (m_SelectionState.Table.Rules.Length > 0) { menu.AddItem(s_ContextMenuDeleteAllLabel, false, () => { SelectRule(-1); m_TargetState.UndoTarget.MarkDirty("Removed all Rules", true); m_SelectionState.Table.Rules = new RSRuleData[0]; }); } else { menu.AddDisabledItem(s_ContextMenuDeleteAllLabel, false); } } menu.ShowAsContext(); }