Hi, I have an abstract class ‘Command’ deriving from ScriptableObject in my custom Node-based Editor. Each Command contains a List of Command which holds a reference to all the Commands that should be run immediately after this Command. All of these Commands are held in a list, and are saved to a MonoBehaviour using Deep Cloning to prevent the saved reference referring to the changing reference.
public static List<Command> CloneCommandList(List<Command> oldCommands)
{
List<Command> newCommands = new List<Command>();
for (int i = 0; i < oldCommands.Count; i++)
{
newCommands.Add(Instantiate(oldCommands*));*
}
return newCommands;
}
This saves the external list, but does not preserve the Lists inside of Command, as the references do not point to the deep cloned version. I do have an idea in mind about finding where the references point to in each list and applying them after the clone, but it’s too late to code here and I think it will take a while, so if anyone has a shortcut/idea, please let me know
Thank you, Tom