protected static void AddCommandCallback(object obj) { AddCommandOperation commandOperation = obj as AddCommandOperation; Block block = commandOperation.block; if (block == null) { return; } Flowchart flowchart = block.GetFlowchart(); flowchart.ClearSelectedCommands(); Command newCommand = Undo.AddComponent(block.gameObject, commandOperation.commandType) as Command; block.GetFlowchart().AddSelectedCommand(newCommand); newCommand.parentBlock = block; newCommand.itemId = flowchart.NextItemId(); // Let command know it has just been added to the block newCommand.OnCommandAdded(block); Undo.RecordObject(block, "Set command type"); if (commandOperation.index < block.commandList.Count - 1) { block.commandList.Insert(commandOperation.index, newCommand); } else { block.commandList.Add(newCommand); } }
//MIKEHACK public void AddCommandHack(Block bl, Type type, int index) { if (bl == null) { return; } Flowchart flowchart = bl.GetFlowchart(); flowchart.ClearSelectedCommands(); Command newCommand = Undo.AddComponent(bl.gameObject, type) as Command; bl.GetFlowchart().AddSelectedCommand(newCommand); newCommand.parentBlock = bl; newCommand.itemId = flowchart.NextItemId(); // Let command know it has just been added to the block newCommand.OnCommandAdded(bl); Undo.RecordObject(bl, "Set command type"); if (index < bl.commandList.Count - 1) { bl.commandList.Insert(index, newCommand); } else { bl.commandList.Add(newCommand); } // Because this is an async call, we need to force prefab instances to record changes PrefabUtility.RecordPrefabInstancePropertyModifications(bl); }
void AddCommandCallback(object obj) { AddCommandOperation commandOperation = obj as AddCommandOperation; Sequence sequence = commandOperation.sequence; if (sequence == null) { return; } sequence.GetFungusScript().ClearSelectedCommands(); Command newCommand = Undo.AddComponent(sequence.gameObject, commandOperation.commandType) as Command; sequence.GetFungusScript().AddSelectedCommand(newCommand); newCommand.parentSequence = sequence; // Let command know it has just been added to the sequence newCommand.OnCommandAdded(sequence); Undo.RecordObject(sequence, "Set command type"); if (commandOperation.index < sequence.commandList.Count - 1) { sequence.commandList[commandOperation.index] = newCommand; } else { sequence.commandList.Add(newCommand); } }
protected static void AddCommandCallback(object obj) { AddCommandOperation commandOperation = obj as AddCommandOperation; Block block = commandOperation.block; if (block == null) { return; } Flowchart flowchart = block.GetFlowchart(); flowchart.ClearSelectedCommands(); Command newCommand = Undo.AddComponent(block.gameObject, commandOperation.commandType) as Command; block.GetFlowchart().AddSelectedCommand(newCommand); newCommand.parentBlock = block; newCommand.itemId = flowchart.NextItemId(); // Let command know it has just been added to the block newCommand.OnCommandAdded(block); Undo.RecordObject(block, "Set command type"); if (commandOperation.index < block.commandList.Count - 1) { block.commandList.Insert(commandOperation.index, newCommand); } else { block.commandList.Add(newCommand); } // Because this is an async call, we need to force prefab instances to record changes PrefabUtility.RecordPrefabInstancePropertyModifications(block); }