Saving Quest States via Script
Posted: Sun Jan 01, 2023 12:48 am
I've been using a Saver script to save most of my data (coins, health, level, etc). But as for quest states, I've just been using the Dialogue System Saver component on my Dialogue Manager.
I'm now making it so players make an account and log in to play, and I'm saving their data on the online PlayFab backend servers. I'll be able to figure out how to save almost everything, except I don't know how to save the Quest States because that's done automatically via the Dialogue System Saver component.
A short version of my Saver script that I got from a tutorial on this website:
Any help will be greatly appreciated!
I'm now making it so players make an account and log in to play, and I'm saving their data on the online PlayFab backend servers. I'll be able to figure out how to save almost everything, except I don't know how to save the Quest States because that's done automatically via the Dialogue System Saver component.
A short version of my Saver script that I got from a tutorial on this website:
Code: Select all
public override string RecordData()
{
var data = new SaveData();
data.currentHealth = GetComponent<PlayerHealth>().currentHealth;
return SaveSystem.Serialize(data);
}
public override void ApplyData(string s)
{
if (string.IsNullOrEmpty(s)) return; // If we didn't receive any save data, exit immediately.
var data = SaveSystem.Deserialize<SaveData>(s);
if (data == null) return;
Debug.Log($"Restoring currentHealth={data.currentHealth}");
GetComponent<PlayerHealth>().healthBar.SetHealth(data.currentHealth);
}