Code: Select all
var savedGameData = SaveSystem.storer.RetrieveSavedGameData(GameManager.Instance.currentSaveSlot);
var s = savedGameData.GetData("playerPositionKey");
if (!string.IsNullOrEmpty(s))
{
var positionData = SaveSystem.Deserialize<PositionSaver.PositionData>(s);
Instantiate(m_playerPref, positionData.position, Quaternion.identity);
}
else
{
var position = GameObject.FindGameObjectWithTag("SpawnPoint").transform.position;
Instantiate(m_playerPref, position, Quaternion.identity);
}
The problem still existed when I was using Pixel Crusher portal. So I added this code to this above:
Code: Select all
if (SaveSystem.playerSpawnpoint != null)
{
Instantiate(m_playerPref, SaveSystem.playerSpawnpoint.transform.position, Quaternion.identity);
}