Browse Source

Fixed: Undo for delete command is broken #161

master
chrisgregan 9 years ago
parent
commit
d7a646c319
  1. 6
      Assets/Fungus/Flowchart/Editor/BlockEditor.cs
  2. 5
      Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs

6
Assets/Fungus/Flowchart/Editor/BlockEditor.cs

@ -991,10 +991,14 @@ namespace Fungus
{ {
command.OnCommandRemoved(block); command.OnCommandRemoved(block);
// Order of destruction is important here for undo to work
Undo.DestroyObjectImmediate(command);
Undo.RecordObject(flowchart.selectedBlock, "Delete"); Undo.RecordObject(flowchart.selectedBlock, "Delete");
flowchart.selectedBlock.commandList.RemoveAt(i); flowchart.selectedBlock.commandList.RemoveAt(i);
Undo.DestroyObjectImmediate(command);
lastSelectedIndex = i; lastSelectedIndex = i;
break; break;
} }
} }

5
Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs

@ -138,6 +138,11 @@ namespace Fungus
{ {
foreach (Command selectedCommand in flowchart.selectedCommands) foreach (Command selectedCommand in flowchart.selectedCommands)
{ {
if (selectedCommand == null)
{
continue;
}
if (selectedCommand.HasReference(variable)) if (selectedCommand.HasReference(variable))
{ {
highlight = true; highlight = true;

Loading…
Cancel
Save