Search Unity

PlayerPrefs webgl problem

Discussion in 'Editor & General Support' started by squigglyo, Apr 2, 2018.

  1. squigglyo

    squigglyo

    Joined:
    May 21, 2012
    Posts:
    107
    I recently published a game on Kongregate.

    Everything worked well while it was in closed beta, but when I published the game, suddenly all save files disappeared.


    I am using PlayerPrefs
    I tested the game before publishing, so it worked just fine until the button was clicked.
    After that button is clicked, the only change I could see was that the url was now different.
    Before it ended with _preview, now it doesnt.

    Are PlayerPrefs tied to the url?
    Is there a way I can access the old PlayerPrefs through my game?
    Is there a way the user can find their old player prefs and move them over to be used in the right spot now?
     
  2. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,071
    PlayerPrefs are indeed tied to the URL, that is how the storage works in the browsers. You can't access them through the new URL, otherwise everyone could just access every other URL.

    You can try writing a tool running from your beta URL for people to upload the settings to your server.
     
  3. squigglyo

    squigglyo

    Joined:
    May 21, 2012
    Posts:
    107
    I dont want to get a server just for a small bit of data and PlayerPrefs just seems way to unreliable for WebGL. About 5% of my users are complaining their games are never saved and various fixes such as allowing cross-domain cookies still doesn't fix it for some of them.

    I guess PlayerPrefs in WebGL, in an iFrame, is just needing a different way to save.
    So im looking at just saving to a file locally.

    But, from what I can tell, if the URL changes so does the persistentDataPath?
    Kongregate has a different URL for Beta versions, other platforms have a different url for every update.

    Either I havent found it or there just doesnt seem to be any real information on how to safe properly on WebGL. Other than cloud, what reliable saving options are there for WebGL/iFrames?
     
  4. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,071
    Cloud is probably the most reliable.