I am trying to save my character data using cloud save. I have a serializable class which holds some data about the character like speed, attack etc. My data is saved nicely in cloud but when I opened it using the dashboard i saw UGS made too many numbers after the decimal point. Suppose my speed is a float value and its set as 0.2f but UGS is saving it as 0.2000065 something like that. Does anyone know why and what i can do to fix this? any help is appreciated, Thanks!
Here is the JSON data from UGS dashboard
Here is my save and load function for saving in cloud.
public static async Task<T> LoadData<T>(string p_key, T p_defaultData)
{
try
{
var data = await CloudSaveService.Instance.Data.Player.LoadAsync(new HashSet<string> { p_key });
if (data.TryGetValue(p_key, out var value))
{
string JSON = value.Value.GetAsString();
T extractedData = JsonUtility.FromJson<T>(JSON);
Debug.Log("loaded: "+ReflectionUtils.PrintDataToString(extractedData));
return extractedData;
}
else
{
Debug.Log("Created: "+ReflectionUtils.PrintDataToString(p_defaultData));
await SaveData(p_key, p_defaultData);
return p_defaultData;
}
}
catch (Exception ex)
{
Debug.Log(ex.Message.ToString());
return p_defaultData;
}
}
public static async Task SaveData<T>(string p_key, T p_data)
{
try
{
string JSON = JsonUtility.ToJson(p_data);
var convertedData = new Dictionary<string, object>
{
{ p_key, JSON}
};
await CloudSaveService.Instance.Data.Player.SaveAsync(convertedData);
Debug.Log("Saved: " + ReflectionUtils.PrintDataToString(p_data));
}
catch (System.Security.Authentication.AuthenticationException ex) { Debug.LogException(ex); }
catch (RequestFailedException ex) { Debug.LogException(ex); }
}