I’m trying to create a simple save/reload system, where objects of many different types need to be saved.
There are many objects with different scripts, and I need copies of those instances with all their variables in whatever state they had at the time of copying.
Setting a GameObject variable with a gameObject in the scene only makes a reference to that object, not a state copy. (i.e if it gets destroyed or altered, the variable is affected).
pseudocode to show my problem:
GameObject objectReference = find("a gameobject");
GameObject objectCopy = objectReference;
print(objectCopy); > console prints "null"
How can I store a copy of a gameObject? Am I going to have to write a custom class to store all the possible data in an instance of a gameObject? If I have to do this, would it be possible to use typecasting? This method would be quite a pain
PS: using C#