Save guid for prefabs that need to be diffrent
-
- Posts: 13
- Joined: Thu Sep 17, 2020 9:55 am
Save guid for prefabs that need to be diffrent
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);
}
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
Hi there,
All the best,
Joel
I'm afraid it's unclear what you mean by this. Please could you clarify?how would i make it so it only saves loads for each of the objects separately
All the best,
Joel
-
- Posts: 13
- Joined: Thu Sep 17, 2020 9:55 am
Re: Save guid for prefabs that need to be diffrent
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.
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
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
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
-
- Posts: 13
- Joined: Thu Sep 17, 2020 9:55 am
Re: Save guid for prefabs that need to be diffrent
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.
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
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
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
-
- Posts: 13
- Joined: Thu Sep 17, 2020 9:55 am
Re: Save guid for prefabs that need to be diffrent
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.
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
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
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
-
- Posts: 13
- Joined: Thu Sep 17, 2020 9:55 am
Re: Save guid for prefabs that need to be diffrent
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.
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.
-
- Posts: 13
- Joined: Thu Sep 17, 2020 9:55 am
Re: Save guid for prefabs that need to be diffrent
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.
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.