ink icon indicating copy to clipboard operation
ink copied to clipboard

Repeating text content when "loading" a saved game

Open olivermarshall2 opened this issue 3 years ago • 4 comments

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

olivermarshall2 avatar Apr 23 '21 13:04 olivermarshall2

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 avatar Apr 23 '21 13:04 olivermarshall2

@olivermarshall2 Thank you for posting your fix to this issue. I was at my wits end with this! Your fix worked!

ThePhilipBooker avatar Feb 03 '22 05:02 ThePhilipBooker

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 avatar Feb 03 '22 07:02 olivermarshall2

@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!

ThePhilipBooker avatar Feb 05 '22 19:02 ThePhilipBooker