My StreamingAssets load function is failing to find the file in a WebGL build.

1
2
3
4
87fe1115-9410-4333-86b8-4f13bd96c86d:8 DirectoryNotFoundException: Could not find a part of the path '/http:/localhost:58316/StreamingAssets/data/events'.
  at System.IO.__Error.WinIOError (System.Int32 errorCode, System.String maybeFullPath) [0x00000] in <00000000000000000000000000000000>:0

(Filename: currently not available on il2cpp Line: -1)

The load function:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
private static string LoadStreamingAsset(string filePath) {
    // string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, fileName);

    string result;
    if (filePath.Contains("://") || filePath.Contains(":///")) {
        WWW www = new WWW(filePath);
        // yield return www;
        result = www.text;
    } else {
        result = System.IO.File.ReadAllText(filePath);
    }
    return result;
}

Where path is something like

1
string path = System.IO.Path.Combine(Application.streamingAssetsPath, "data/villageCenter/stats");