Been using EasySave for my project I've been working on .
One hurdle I've come across is being able to save a list of gameobject Active States once the item is innactive on the hierarchy. I used the below snippet of code in ES2 for testing.
Code: Select all
public void OnDestroy()
{
// Save the enabled state when the scene/object is destroyed.
ES2.Save(gameObject,gameObject.activeSelf, "myFile.txt?tag=active" + gameObject.name);
}
public void Start()
{
// Check if there's an active state to load. If there is, load our active state.
if(ES2.Exists("myFile.txt?tag=active" + gameObject.name))
gameObject.SetActive( ES2.Load<bool>( "myFile.txt?tag=active" + gameObject.name ) );
}
}
However, I do not want the item to save it's active state unless the player saves the game. If the player dies and restarts from the last save I don't want the items to be disabled.
I figured that a possibility is to change the code to add the item to a list with it's activeState when OnDestroy() is called. Then that list of items with activestates would be saved when the player actually saves the game. I'd imagine i would just have a loop on the save function to iterate through the collection I am trying to make to save. But I'm struggling getting something like that to work.
I have scriptableObjects that hold the object data during the playthrough. Is it possible to just save those scriptable object files on save?
Any assistance is appreciated! Thanks!