Loading Twice

Discussion and help for Easy Save 3
Post Reply
usingeasysave3
Posts: 1
Joined: Tue Sep 06, 2022 4:43 pm

Loading Twice

Post by usingeasysave3 »

Hello,
I am trying to load a prefab that I instantiated in run time, and this prefab has some children and different components in each one. I use a button to load, and when I click the button once, it loads the prefab but some of the children are in the wrong positions. Based on the other posts I read, I think I have to load twice to load the instances first and load their fields correctly. But I'm not sure how I will go about doing that. Clicking the load button twice works, but it's obviously not what I want to do for gameplay. I tried repeating or changing the order of lines in the code, but that didn't work. I'm not sure if there is something else wrong with my setup or code. Here is my code below. I will appreciate it greatly if you could take a look at it to see what's wrong with it. Thank you.

public void Save()
{
ES3AutoSaveMgr.Current.Save();
GetChildrenofPrefabList(prefabParent);
ES3.Save("listofPrefabs)", listofPrefabs);
}

public void Load()
{
ES3AutoSaveMgr.Current.Load();
listofPrefabs = ES3.Load<List<GameObject>>("listofPrefabs)");
}

public void GetChildrenofPrefabList(GameObject obj)
{
foreach (Transform child in obj.transform)
{
listofPrefabs.Add(child.gameObject);
}
}
Post Reply