- Home /
[c#] Save an instance for future re-instantiation
Hi, this may be a stupid question but I cant find out how to do this...
I need to save the entire instance (or state) of a gameobject in memory to re-instantiate it in a second moment. If I write GameObject tmp = GameObject.Find("/myObject"), o = tmp; Destroy(tmp);
in the variable 'o' only goes a REFERENCE of the gameobject, not an instance copy (which is what I need)! So when I write GameObject newInstance = Instantiate(o) as GameObject; it ends in a MisingReferenceException because the former gameobject was destroyed so its instance is no longer present in memory.
Anyone can give me a hint to achieve this task?
Your answer
![](https://koobas.hobune.stream/wayback/20220613090748im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Store reference to array as variable 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Can you store a reference to a primitive value? 1 Answer
c# How does an == decide if two objects are the same? 1 Answer