Answer the question
In order to leave comments, you need to log in
How to move an Array from one scene to another?
We need to transfer the Array of GameObjects from one scene to another.
I tried to do it through DontDestroyOnLoad, but in another scene, the objects disappear from the array.
Is there a way to do this without using Json type persistence methods, etc. ?
Or just by saving in one scene and parsing in another?
public GameObject myCollectionCard;
public GameObject[] myPullCard;
private void Awake()
{
myPullCard = new GameObject[myCollectionCard.transform.childCount];
DontDestroyOnLoad(gameObject);
}
public void GetMyPullCard()
{
for (int i = 0; i < myPullCard.Length; i++)
{
myPullCard[i] = myCollectionCard.transform.GetChild(i).gameObject;
}
}
Answer the question
In order to leave comments, you need to log in
Put all objects as children in one rootObject. You make this rootObject DontDestroyOnLoad. You hang a script on it, into the array of which you drive all the necessary objects.
After loading the scene, both the array is intact and the objects.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question