Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question OnBeforeSerialize for ForceSaveAsync

Discussion in 'Cloud Save' started by helloroy, Dec 19, 2022.

  1. helloroy

    helloroy

    Joined:
    Jun 23, 2016
    Posts:
    42
    Hello,

    I need to handle variables in OnBeforeSerialize() and OnAfterDeserialize(), but seems CloudSaveService.Instance.Data.ForceSaveAsync() will not work with OnBeforeSerialize(), I can only pass serialized Object before ForceSaveAsync to let it work, for example:

    Code (CSharp):
    1. var data = new Dictionary<string, object> { { typeof(T).Name, JsonUtility.ToJson(Instance) } };
    2. await CloudSaveService.Instance.Data.ForceSaveAsync(data);
    So, does ForceSaveAsync not use JsonUtility to handle Serialization, and why? and how can I implement OnBeforeSerialize() for ForceSaveAsync?

    Thanks
     
  2. MileyUnity

    MileyUnity

    Unity Technologies

    Joined:
    Jan 3, 2020
    Posts:
    92
    Hey there, under the hood the CloudSave SDK uses Newtonsoft Json to serialize the data. I've not used OnBeforeSerialize nor OnAfterSerialize yet with CloudSave so I can't help much with that unfortunately
     
  3. helloroy

    helloroy

    Joined:
    Jun 23, 2016
    Posts:
    42
    Thanks for your reply, but OnBeforeSerialize and OnAfterSerialize are quite helpful for some cases, do you guys have any plan to add them to CloudSave in the future?