itch.io is community of indie game creators and players

Saving game data for web based games hosted in itch.io and built in Unity

I recently noticed that player' game data was being lost between updates. My game MurderDeathKill is hosted on itch.io and built in Unity (WebGL). The reason turned out to be that game data is saved in IndexedBD and the path used by Application.persistentDataPath has a GUID as part of the path which is updated on each new build. The fix was to set the path for WebGL builds instead of using Application.persistentDataPath 


    private string GetSavePath(string filename)
    {
        var path = Application.persistentDataPath;
        #if UNITY_WEBGL && !UNITY_EDITOR
         path = "/idbfs/murder-death-kill";
          if (!Directory.Exists(path)) {
             Directory.CreateDirectory(path);
             Debug.Log("Creating save directory: " + path);
         }
        #endif
        var result = Path.Combine(path, filename);
        Debug.Log("Save path: " + result);
        return result;
    }

Hope this helps. You can play Murder Death Kill at https://codedragons.itch.io/murder-death-kill

Leave a comment