Saving custom script values
Posted: Wed Jan 10, 2024 1:19 am
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)
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.
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.
I haven't tried to load because I just check the save file and the values there.
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 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);