First of all I'm very happy with this plugin very good job
I have some trouble using EasySave with my scriptable objects, hope someone can help me here
I'm using the cache class example to achieve my player manager that is responsible of the player save.
I have a main ScriptableObject "PlayerData" that have an array of other SciptableObjects called "GameItems".
If I do save the PlayerData, all is saved correctly, but when quit the application the PlayerData Scriptable Object has its list of GameItems all reset to none.
The length of the array is not touched, just the content.
When I reload the save file, all goes back in place (except the names of the SOs).
Here is my data strucutre in two classes for now :
Code: Select all
public class PlayerData : ScriptableObject
{
public string nickname;
public int scraps;
public GameItemData[] gameItems;
public void Reset()
{
nickname = "Player";
scraps = 0;
foreach (GameItemData item in gameItems)
{
item.Reset();
}
}
}
public class GameItemData : ScriptableObject
{
public string uid;
public string title;
public Texture2D image;
public bool owned;
public void Reset()
{
owned = false;
}
}
Code: Select all
public class PlayerManager : MonoBehaviour
{
public PlayerData player;
public static ES3File file;
public static PlayerManager instance = null;
void Awake()
{
if (instance == null)
{
instance = this;
}
else if (instance != this)
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);
}
public void Start()
{
// Create a new ES3File. This automatically loads
// the data from claytus.save into the ES3File.
file = new ES3File("claytus.save");
// If the save file exists load it
// If not, reset the player data to default
if (ES3.FileExists("claytus.save"))
{
Load();
}
else
{
Reset();
}
}
public void OnApplicationQuit()
{
file.Sync();
}
public static void Save()
{
file.Save<PlayerData>("player", instance.player);
}
public static void Load()
{
if (file.KeyExists("player"))
{
file.LoadInto<PlayerData>("player", instance.player);
}
}
private void Reset()
{
instance.player.Reset();
}
}
Here what looks like my inspector (I'm using Odin) before any save or load, these are the default values typed in the inspector :
Here what does looks like my inspector after loading the player data (the game is still running) :
And finally here is what looks like my inspector after quitting the application :
Hope you can help me with his
Have a nice day!