Saving custom script values

Discussion and help for Easy Save 3
Post Reply
Notso
Posts: 51
Joined: Sat May 08, 2021 6:53 pm

Saving custom script values

Post by Notso »

I mentioned this in another thread but figured I would start over.
I have an EMPTY. as a child I have an object with the script I need to save.
I have get/set for protected variables.
(example)

Code: Select all

[SerializeField] [Range(0, 1)]      protected float _bodyArmour  

Code: Select all

public float            bodyArmour
    {
        get { return _bodyArmour; }
        set { _bodyArmour = value; }
    }

I even tried adding [ES3Serializable] before the public float.
It only saves the default value, never the changed value. If it starts at 0, and I change it to 15, it saves as 0.

I use a list for the game object NPCs. Drag the NPC parent object into that list in the inspector.

Code: Select all

public List<GameObject> enemies = new List<GameObject>();
I right click add ES3Prefab on the empty parent (in the assets folder). On the child object I added es3gameobject and checked the box for the script aistatemachine
I then even went into types, properties and selected the values I wanted saved. Still only saves the default value.

Code: Select all

ES3.Save("Enemies", enemies);
I haven't tried to load because I just check the save file and the values there.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving custom script values

Post by Joel »

Hi there,

Please could you replicate this in a new project with a simple scene and send me a link to it on moodkie.com/contact along with step-by-step instructions.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Notso
Posts: 51
Joined: Sat May 08, 2021 6:53 pm

Re: Saving custom script values

Post by Notso »

I would like to but that would be almost impossible.
This is in a complete project and trying to remember/figure out what scripts and the full set up again would be a serious task.
Other than the players missions in place, the game is complete.
The AI requires a player and a manager, the player requires a UI, a manager, multiple SO setups, a PVS system, a lockpicking system etc...
The application manager requires a few things too and to be loaded before the scene.
(In other words, all systems are tied to others now, beyond the ability to comment out the things not needed for just testing).
Didn't really think about saving until after it all worked.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving custom script values

Post by Joel »

Hi there

You would just need to create a project which contains some basic prefabs and a script with the List to contain them and the properties. If it works in this basic project then it would indicate that the issue is with your logic which unfortunately I wouldn't be able to assist with.

If that is the case I recommend making a copy of your main project and removing things until the issue no longer occurs to narrow down what is causing the issue.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Notso
Posts: 51
Joined: Sat May 08, 2021 6:53 pm

Re: Saving custom script values

Post by Notso »

Gotcha. I did try that, and it seems to work.
OMFG...HOW STUPID...
Hahaha, it was saving the actual prefab from assets, not the prefab in the scene!
OK..time to move on..haha.
Once I get the values saved and loaded I will work on the transform (which I know we I had issues with before...be back later, I apparently need sleep after this!)
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving custom script values

Post by Joel »

Glad you managed to find the issue :)

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