Load and Save not working

Discussion and help for Easy Save 3
Post Reply
stromecek555
Posts: 3
Joined: Tue Dec 06, 2022 6:39 pm

Load and Save not working

Post by stromecek555 »

hi, I need help, I'm trying to save or load data but it doesn't work, what's up with that?thank you
Attachments
Snímek obrazovky (783).png
Snímek obrazovky (783).png (203.22 KiB) Viewed 270 times
Snímek obrazovky (781).png
Snímek obrazovky (781).png (111.54 KiB) Viewed 270 times

User avatar
Joel
Moodkie Staff
Posts: 4362
Joined: Wed Nov 07, 2012 10:32 pm

Re: Load and Save not working

Post by Joel »

Hi there,

Please could you show me the code you’re using to save and load?

Also you have an error regarding an unassigned reference which is unrelated to Easy Save, but could prevent Easy Save from being able to serialize your data. If this related to something you are saving you should resolve this error.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started

stromecek555
Posts: 3
Joined: Tue Dec 06, 2022 6:39 pm

Re: Load and Save not working

Post by stromecek555 »

Hello, thank you for your reply and here are the codes

Code: Select all

public class Load : MonoBehaviour
{
    


    public void LoadSave()
    {
        MaterialsData script = GetComponent<MaterialsData>();
        script.Iron = ES3.Load<int>("Iron");
        script.Scrap = ES3.Load<int>("Scrap");
        script.Wood= ES3.Load<int>("Wood");
        script.Glue = ES3.Load<int>("Glue");
        script.String = ES3.Load<int>("String");
        script.Brass = ES3.Load<int>("Brass");
        script.GunPowder = ES3.Load<int>("GunPowder");
        Debug.Log("Load");
    }
}using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Save : MonoBehaviour
{
   
    
   
    public void Saves()
    {
        MaterialsData script = GetComponent<MaterialsData>();
        ES3.Save(script.Iron,"Iron");
        ES3.Save(script.Scrap,"Scrap");
        ES3.Save(script.Wood,"Wood");
        ES3.Save(script.Glue,"Glue");
        ES3.Save(script.String,"String");
        ES3.Save(script.Brass,"Brass");
        ES3.Save(script.GunPowder,"GunPowder");
        Debug.Log("Save");
    }
}

User avatar
Joel
Moodkie Staff
Posts: 4362
Joined: Wed Nov 07, 2012 10:32 pm

Re: Load and Save not working

Post by Joel »

Hi there,

You have the parameters the wrong way around in your ES3.Save calls. The key comes first and the value comes second. See the Getting Started guide and docs for more information:

https://docs.moodkie.com/easy-save-3/getting-started/

I also recommend deleting your existing save data by going to Tools > Easy Save 3 > Clear PersistentDataPath, as it will now contain incorrect data.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started

stromecek555
Posts: 3
Joined: Tue Dec 06, 2022 6:39 pm

Re: Load and Save not working

Post by stromecek555 »

thank you, but could you show me an example? advise me, they throw me an error, what about it?
Attachments
Snímek obrazovky (789).png
Snímek obrazovky (789).png (184.52 KiB) Viewed 247 times

User avatar
Joel
Moodkie Staff
Posts: 4362
Joined: Wed Nov 07, 2012 10:32 pm

Re: Load and Save not working

Post by Joel »

Hi there,

defaultValue should be the value that you want to return if Save data doesn’t exist. As you haven’t declared a variable named defaultValue, this will throw a compilation error (this is a programming error rather than an error at our end).

Also note that your ES3.Save calls still have the parameters the wrong way around.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started

Post Reply