3

Currently, I have a lot of data stored using PlayerPrefs, such as total scores, important indices, and more.

How can I best save PlayerPrefs data in a WebGL game in the event that data gets cleared when the players clear their browser history?

Craig Conover
  • 4,710
  • 34
  • 59
shelly peng
  • 107
  • 8
  • You can use [PubNub Objects](https://www.pubnub.com/blog/introducing-objects-v2-store-for-user-and-channel-metadata/) to store these PlayerPrefs. Look at [`setUUIDMetadata`](https://www.pubnub.com/docs/sdks/unity/api-reference/objects#set-user-metadata). – Craig Conover Mar 13 '21 at 17:54
  • Your client code can `setUUIDMetadata` when things need to be updated, and on the *receiving end* of that update, you can capture the confirmation of those changes using the `UserEventResult` callback of the [`SubscribeCallbackHandler `](https://www.pubnub.com/docs/sdks/unity/api-reference/configuration#adding-listeners). Though that last part is optional. It allows you to listen to other player's user updates, too, if that is preferred/required. Hit [PN Support](https://support.pubnub.com) for more if needed! – Craig Conover Mar 13 '21 at 18:03
  • For about PubNub Objects *User/UUID Metadata*, see https://www.pubnub.com/docs/connections/users-metadata – Craig Conover Mar 13 '21 at 18:08
  • You can use [`SetChannelMetadata`](https://www.pubnub.com/docs/sdks/unity/api-reference/objects#set-channel-metadata) for non-user (game scope) state that needs to be persisted. – Craig Conover Mar 13 '21 at 20:32

0 Answers0