Code: Select all
SaveSystem.SaveToSlot(GameManager.Instance.currentSaveSlot);
Code: Select all
SaveSystem.SaveToSlot(GameManager.Instance.currentSaveSlot);
Code: Select all
public Vector3 GetCheckpointLocation()
{ // Assume we run this on the player.
var uccSaver = GetComponent<uccSaver>();
var s = SaveSystem.currentSavedGameData.GetData(uccSaver.key);
var data = SaveSystem.Deserialize<UCCSaver.Data>(s);
return data.position;
}
Code: Select all
public class MyUCCPlayerSaver : UCCSaver // Put this on player instead of UCCSaver.
{ // Assumes you're calling SaveSystem.SaveToSlotImmediate() or using AutoSaveLoad to save when quitting.
private bool isQuitting = false;
void OnApplicationQuit()
{
isQuitting = true;
}
public override string RecordData()
{
Vector3 checkpointLocation = GetCheckpointLocation();
var s = base.RecordData();
if (isQuitting)
{ // Store previous checkpoint position in save data:
var data = SaveSystem.Deserialize<UCCSaver.Data>(s);
data.position = checkpointLocation;
s = SaveSystem.Serialize(data);
}
return s;
}
}