question

Yoo SeungJi avatar image
Yoo SeungJi asked

About Set data OnApplicationQuit

This question could be about Unity.

If it is not important data, I am thinking of not updating it to the server immediately after the change, but only in special circumstances. I'm considering updating the application when I close it this way, what do you think about this?

Player DatadataCharacter Data
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sarah Zhang avatar image
Sarah Zhang answered

Setting the data in the OnApplicationQuit() function is ok. The code could be something like this code snippet of PlayFab SDK.

Of course, we would still suggest you store the data regularly including saving the data locally to prevent data loss due to program crashes. If as you said, the data is not important, you can entirely store the data temporarily locally, then upload it when the application quit. If so, when the game crashes, the client can still hold the data and wait for the next upload.

Besides, you can also consider using the Unity method Unity - Scripting API: Application.quitting (unity3d.com) or Unity - Scripting API: Application.wantsToQuit (unity3d.com) to raise the event when the application quitting. If you have the more advanced questions about Unity API and the Unity script life cycle, please navigate to the Unity forum for the professional support.

4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Yoo SeungJi avatar image Yoo SeungJi commented ·

@Sarah Zhang Thank you, but I have one question. Is there a way to distinguish if the server's data and local backup data are different when receiving user data from the server, whether it is tampered with or not uploaded to the server?

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Yoo SeungJi commented ·

Generating MD5 value for local data file can prevent some cheaters. Or you can consider using asymmetric encryption for your data, you can encrypt it in Unity, and unencrypt it on Cloud Script using Azure Functions.

But if you have high security requirements for this part of the data, please upload the encrypted data directly instead of storing it locally.

0 Likes 0 ·
Yoo SeungJi avatar image Yoo SeungJi Sarah Zhang commented ·

Thank you for your kind answer.
I'm sorry, but could you explain the encryption in detail?

0 Likes 0 ·
Show more comments
Jung Ho June avatar image
Jung Ho June answered

i was used that solution for my ue4 game

but sometimes the data not upload so it cause critical error.

so i decided to auto upload every 50 sec.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.