Game Crashes upon calling ES3.Save()

Discussion and help for Easy Save 3
Post Reply
austin_weeks
Posts: 1
Joined: Sun Dec 10, 2023 1:16 am

Game Crashes upon calling ES3.Save()

Post by austin_weeks »

Hi there,

I'm new to using easy save and am currently having trouble. I'm attempting to refactor my existing save system to utilize easy save. However, I'm running into an issue where my game/Unity freezes upon calling the ES3.Save() method. I'm trying to save a PlayerStatsData class, listed below:

Code: Select all

[Serializable]
[ES3Serializable]
public class PlayerStatsData
	{
		public bool tutorialCompleted;
		
		public ShipType shipType;
		public int goldAmount;
		public int scrapsAmount;
		public int gemAmount;
		
		public ShipStats sloop;
		public ShipStats schooner;
		public ShipStats galleon;
	}
I'm using the following method to gather the correct data and save using ES3.Save()

Code: Select all

string PLAYER_STATS_DATA = "PlayerStatsData";
public static void SavePlayerStatsData()
	{
		PlayerStatsData playerData;
				
		if (!Player.Instance)
		{
			playerData = GetDefaultPlayerShipData();
			playerData.tutorialCompleted = completeTutorial;
		}
		else
		{
			PlayerShipStats playerShipStats = PlayerShipStats.Instance;
			PlayerCurrencies playerCurrencies = PlayerCurrencies.Instance;
			playerData = new PlayerStatsData
			{
				tutorialCompleted = CheckTutorialCompletion(),

				shipType = playerShipStats.currentShip,
				goldAmount = playerCurrencies.GetPlayerGold(),
				scrapsAmount = playerCurrencies.GetPlayerScraps(),
				gemAmount = playerCurrencies.GetPlayerGems(),
				
				sloop = playerShipStats.sloop,
				schooner = playerShipStats.schooner,
				galleon = playerShipStats.galleon,
			};
		}
		
		ES3.Save(PLAYER_STATS_DATA, playerData);
	}
I have a separate method that loads from the PLAYER_STATS_DATA key and calls a method that returns a default PlayerSavesData object if the key does not exist, and this is working perfectly fine. However, when the game calls the SavePlayerStatsData() method listed above, Unity completely freezes. The class I'm trying to save, as well as the class fields within this class all have the [Serializable] and [ES3Serializable] attributes.
I'm at a loss as to what's causing this issue, so any help is greatly appreciated!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Game Crashes upon calling ES3.Save()

Post by Joel »

Hi there,

If Unity crashes then it should produce an editor log file containing information towards the end of the log file. Please could you access this (https://docs.unity3d.com/Manual/LogFiles.html) and let me know what is at the end of the log file.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply