Page 1 of 1

Save guid for prefabs that need to be diffrent

Posted: Tue Jul 27, 2021 3:59 pm
by seaniboy2009
Hi,

Was looking for some advice, i have say an item stash that will save the current items in it, but the player can build more, how would i make it so it only saves loads for each of the objects separately.

code below:

public void LoadSavedItems()
{
if (ES3.KeyExists("FurnaceList"))
{
Debug.Log("FurnaceList save exist");
currentItems = ES3.Load("FurnaceList", currentItems);

Clear();
for (int i = 0; i < currentItems.Count; i++)
{
AddItem(currentItems.GetCopy());
}
}
}

public void OnApplicationQuit()
{
SaveFurnace();
}

public void SaveFurnace()
{
ES3.Save("FurnaceList", currentItems);
}

Re: Save guid for prefabs that need to be diffrent

Posted: Tue Jul 27, 2021 4:21 pm
by Joel
Hi there,
how would i make it so it only saves loads for each of the objects separately
I'm afraid it's unclear what you mean by this. Please could you clarify?

All the best,
Joel

Re: Save guid for prefabs that need to be diffrent

Posted: Wed Jul 28, 2021 9:35 am
by seaniboy2009
Hi Joel,

Yes sorry, i have two stash game objects both are a prefab, the player can place items into this, and the game can then save the list of items, but how do i save them separately, so when it is loaded the two stashes dont have the same items in there, if i use a guid, its the same for both stashes as they are a clone of the prefab.

so what i need to know is how both stashes with the same script can have two separate save files that are unique to them.

Re: Save guid for prefabs that need to be diffrent

Posted: Wed Jul 28, 2021 11:06 am
by Joel
Hi there,

Are you following the saving and loading prefab instances instructions? Easy Save automatically assigns unique GUIDs, so you don't need to generate your own:
https://docs.moodkie.com/easy-save-3/es ... s-prefabs/

All the best,
Joel

Re: Save guid for prefabs that need to be diffrent

Posted: Wed Jul 28, 2021 11:46 am
by seaniboy2009
Hi Joel,

Yes, well i think i am going by the link you sent me, my code below, but the issue is if there are more than 1 prefab they all get the same list added to them because it loads the same list.

public void SaveFurnace()
{
ES3.Save("FurnaceList", currentItems);
}

so for each of the furnaces they all save via the above then they all load from the above, i think its because they all save to the "FurnaceList" and all load from the "FurnaceList" save file.

Re: Save guid for prefabs that need to be diffrent

Posted: Wed Jul 28, 2021 12:09 pm
by Joel
Hi there,

I've had no reports of this and it appears to be working fine at my end.

Please could you replicate this in a new, empty project using the latest version of Easy Save with a simple scene and private message it to me so I can see what is happening.

All the best,
Joel

Re: Save guid for prefabs that need to be diffrent

Posted: Wed Jul 28, 2021 3:35 pm
by seaniboy2009
Sorry i don't think i am explaining this correctly.

I have 2 objects in the scene with the same script attached, both save on application quit, both use this ES3.Save("FurnaceList", currentItems);(this is a list of scriptable objects)

so for example i have:

furnace A
furnace B

i then add

Ore to furnace A
rock to furnace B

when i save then load the map again both furnace A and furnace B have the ore.

Re: Save guid for prefabs that need to be diffrent

Posted: Wed Jul 28, 2021 4:23 pm
by Joel
Hi there,

If you're not using Easy Save to manage references, you would need to provide a unique ID as a key for each list that you save.

Alternatively you could save and load the Components themselves, so Easy Save is able to manage the reference IDs for you.

All the best,
Joel

Re: Save guid for prefabs that need to be diffrent

Posted: Sat Jul 31, 2021 12:12 pm
by seaniboy2009
Hi Joel,

I got it working with using the autosave and removing the save and load code, it saves all the items and loads them per game object, however for some reason some of the game objects appear invisible, its still there and the colliders and such are all there but you cant see it, i investigated and it looks like the mesh filter is being set to none when it loads the object and i am not sure why.

Re: Save guid for prefabs that need to be diffrent

Posted: Sat Jul 31, 2021 12:39 pm
by seaniboy2009
Ok i have found the issue and resolved.

If the mesh filter mesh name has the same name as anything else in the scene it cant load it, the mesh was called plane and there was another mesh with that name, i imported to blender renamed the mesh and imported again and the issue is resolved.