示例#1
0
        protected void Delete()
        {
            Sequence     sequence     = target as Sequence;
            FungusScript fungusScript = sequence.GetFungusScript();

            if (fungusScript == null ||
                fungusScript.selectedSequence == null)
            {
                return;
            }

            for (int i = fungusScript.selectedSequence.commandList.Count - 1; i >= 0; --i)
            {
                Command command = fungusScript.selectedSequence.commandList[i];
                foreach (Command selectedCommand in fungusScript.selectedCommands)
                {
                    if (command == selectedCommand)
                    {
                        command.OnCommandRemoved(sequence);

                        Undo.RecordObject(fungusScript.selectedSequence, "Delete");
                        fungusScript.selectedSequence.commandList.RemoveAt(i);
                        Undo.DestroyObjectImmediate(command);

                        break;
                    }
                }
            }

            Undo.RecordObject(fungusScript, "Delete");
            fungusScript.ClearSelectedCommands();

            Repaint();
        }
示例#2
0
        protected void Delete()
        {
            Block     block     = target as Block;
            Flowchart flowchart = block.GetFlowchart();

            if (flowchart == null ||
                flowchart.selectedBlock == null)
            {
                return;
            }
            int lastSelectedIndex = 0;

            for (int i = flowchart.selectedBlock.commandList.Count - 1; i >= 0; --i)
            {
                Command command = flowchart.selectedBlock.commandList[i];
                foreach (Command selectedCommand in flowchart.selectedCommands)
                {
                    if (command == selectedCommand)
                    {
                        command.OnCommandRemoved(block);

                        // Order of destruction is important here for undo to work
                        Undo.DestroyObjectImmediate(command);

                        Undo.RecordObject(flowchart.selectedBlock, "Delete");
                        flowchart.selectedBlock.commandList.RemoveAt(i);

                        lastSelectedIndex = i;

                        break;
                    }
                }
            }

            Undo.RecordObject(flowchart, "Delete");
            flowchart.ClearSelectedCommands();

            if (lastSelectedIndex < flowchart.selectedBlock.commandList.Count)
            {
                Command nextCommand = flowchart.selectedBlock.commandList[lastSelectedIndex];
                block.GetFlowchart().AddSelectedCommand(nextCommand);
            }

            Repaint();
        }