I'm having trouble understanding how to use the custom states feature. I've created a new blank project to test this, and I'm pretty much ready to start bashing my head into my desk because I'm doing exactly what the guide says to do and it's not working. All I have is an object with the example custom state code attached, from https://naninovel.com/guide/state-manag ... stom-state.
I start the game.
I hit "New Game".
I change myCustomString to "apple" with the inspector.
I save the game.
Then I quit back to the main menu.
I change myCustomString to "banana" with the inspector.
Then I load the save.
myCustomString is still "banana".
How do I get the SerializeState and DeserializeState methods to work? Should I be calling them somewhere? Am I missing some crucial step? Even after looking at the inventory system example, I'm completely at a loss about what to do next.
Thanks for the suggestion, but as I already stated, I've reviewed the Inventory system example and it didn't make things any clearer to me. I can't find anything explaining how the SerializeState() and DeserializeState() methods are supposed to be invoked.
Thanks for the suggestion, but as I already stated, I've reviewed the Inventory system example and it didn't make things any clearer to me. I can't find anything explaining how the SerializeState() and DeserializeState() methods are supposed to be invoked.
Sorry, I missed that part of the question. But yeah as stated by Elringus, these are invoked automatically via the tasks added during OnEnable() and OnDisable() in the custom state example.
Thank you both for your help, but I'm afraid I'm not any closer to getting this working. I've created a completely new project in the April 2019 Unity build that's mentioned as being the most stable, and I've redownloaded the Naninovel package from the asset store. All I have in the project is a single GameObject tied to the example MyCustomBehavior script found here, copy/pasted https://naninovel.com/guide/state-manag ... obal-state and then modified to include a setter for myCustomString. I've also created a custom command whose only purpose is to set the value of myCustomString.
private void OnEnable()
{
stateManager.AddOnGameSerializeTask(SerializeState); // this is the line where the NullReferenceException occurs
stateManager.AddOnGameDeserializeTask(DeserializeState);
}
And, needless to say, the changes that I make to myCustomString are not being saved or restored.
That explains the issue: stateManager is not assigned at the time you're attempting to access it. Make sure to assign the variable before using it. Also, check this: https://naninovel.com/guide/integration ... engine-api