- Home /
How do you save GameObject[]?
Hello, essentially what I'm trying to do is to save a GameObject[] array and all GameObject element positions in that array (NOTE- I DO NOT MEAN TRANSFORM POSITION). However, GameObject[] cannot be saved into PlayerPrefs or PlayerPrefsX. Neither can they be serialized. The most important aspect of this is saving the the GameObjects element position in my GameObject[] array, since they shift around during gameplay.
Any solutions?
You could give them unique names and serialise the names ins$$anonymous$$d?
Answer by Cherno · Sep 16, 2014 at 03:12 PM
What MGB said. Write a simple ID script that assigns a unique ID every time a gameobject is instntiated or needs to be saved (if it hasn't already have one). A static variable tracking the number ob objects is handy for this. You can then store the Reference ID and use it to find the gameobject after loading.
Your answer
![](https://koobas.hobune.stream/wayback/20220613163124im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
ArrayPrefs 2 (PlayerPrefs X) Question 2 Answers
Saving usermade creations in game 1 Answer
Save Datasets at runtime 2 Answers
How to see what element is the current one 2 Answers
Get all other GameObjects (not the one script is attached to) 2 Answers