Hello community I am trying to save on the cloud what could be the best way to save a Json file in the cloud?
The Json file code that I am wishing to save
void Save_player_data()
{
player_data = new Player_data()
{
gold = DataController.instance.gold,
cash = DataController.instance.cash,
boost_value = TimeManager.instance.current_boostValue_gameplay,
ad_info = in_app_manager.banner_ad
};
string json = JsonUtility.ToJson(player_data,true);
File.WriteAllText(Application.persistentDataPath + "/player_data.json", json);
}
public void Load_player_data()
{
string save_string = File.ReadAllText(Application.persistentDataPath + "/player_data.json");
player_data = JsonUtility.FromJson<Player_data>(save_string);
if (File.Exists(Application.persistentDataPath + "/player_data.json"))
{
DataController.instance.gold = player_data.gold;
DataController.instance.cash = player_data.cash;
TimeManager.instance.current_boostValue_gameplay = player_data.boost_value;
in_app_manager.banner_ad = player_data.ad_info;
}
else return;
}
And the class which I am wishing to use
public void LoadFromCloud(Action<string> afterLoadAction)
{
if (isAuthenticated && !isProcessing)
{
StartCoroutine(LoadFromCloudRoutin(afterLoadAction));
}
else
{
Login();
}
}
public void SaveToCloud(string dataToSave)
{
if (isAuthenticated)
{
loadedData = dataToSave;
isProcessing = true;
((PlayGamesPlatform)Social.Active).SavedGame.OpenWithAutomaticConflictResolution(m_saveFileName, DataSource.ReadCacheOrNetwork, ConflictResolutionStrategy.UseLongestPlaytime, OnFileOpenToSave);
}
else
{
Login();
}
}