ink
ink copied to clipboard
Repeating text content when "loading" a saved game
Hi all
I'm using the following to load my save from PlayerPrefs in Unity.
story = new Story(inkJSONAsset.text); var savedState = PlayerPrefs.GetString("inkSaveState"); story.state.LoadJson(savedState); RefreshView();
When I do this, it shows the options suitable for that part of the story, but it doesn't show the content, only the choices. I'm using the standard Ink Example that comes with the ink unity asset.
What should I be doing to have it output the content after loading from PlayerPrefs?
Olly
I think I've fixed it. I moved my save game call to the OnClickChoiceButton function just before the RefreshView() is called.
Like so
` void OnClickChoiceButton(Choice choice) { contentButtonAudioSource.Play(); story.ChooseChoiceIndex(choice.index);
//Save Game before content is shown
SaveGame();
RefreshView();
}`
Now when the game loads it carries on from there and shows the text.
@olivermarshall2 Thank you for posting your fix to this issue. I was at my wits end with this! Your fix worked!
Np
I've actually now started to put the current story text in to a variable, along with the Choice.
Then when the player hits save, I save the variables not the live data, of that makes sense. Means that the player can save whenever they like.
@olivermarshall2 That is actually a brilliant idea. I'll save story text to a string and then bring it back on load. Thanks for yet ANOTHER helpful hint!