Browse Source

Duplicate sequence now copies the event handler

master
chrisgregan 10 years ago
parent
commit
a5095ef009
  1. 15
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

15
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

@ -544,6 +544,8 @@ namespace Fungus
Sequence newSequence = FungusScriptWindow.CreateSequence(fungusScript, newPosition); Sequence newSequence = FungusScriptWindow.CreateSequence(fungusScript, newPosition);
newSequence.sequenceName = oldSequence.sequenceName + " (Copy)"; newSequence.sequenceName = oldSequence.sequenceName + " (Copy)";
Undo.RecordObject(newSequence, "Duplicate Sequence");
foreach (Command command in oldSequence.commandList) foreach (Command command in oldSequence.commandList)
{ {
System.Type type = command.GetType(); System.Type type = command.GetType();
@ -555,6 +557,19 @@ namespace Fungus
} }
newSequence.commandList.Add(newCommand); newSequence.commandList.Add(newCommand);
} }
if (oldSequence.eventHandler != null)
{
EventHandler eventHandler = oldSequence.eventHandler;
System.Type type = eventHandler.GetType();
EventHandler newEventHandler = Undo.AddComponent(fungusScript.gameObject, type) as EventHandler;
System.Reflection.FieldInfo[] fields = type.GetFields();
foreach (System.Reflection.FieldInfo field in fields)
{
field.SetValue(newEventHandler, field.GetValue(eventHandler));
}
newSequence.eventHandler = newEventHandler;
}
} }
protected static void ShowSequenceInspector(FungusScript fungusScript) protected static void ShowSequenceInspector(FungusScript fungusScript)

Loading…
Cancel
Save