Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

403 error first time loading a data file from streamingAssetsPath in unity webGL build

A topic by tinkerla created Sep 02, 2019 Views: 1,389 Replies: 2
Viewing posts 1 to 3

On the very first attempt to load a data file from the streamingAssetsPath (i.e. I upload a new build to itch, and the VERY first time I run that build), on a  Unity webGL build, on itch, I see a 403 error. Reloading the page, and running the game again, everything works fine and requests to load the data file via UnityWebRequest work as expected. Running this NOT on itch, everything works fine. Has anyone else seen a similar case? Any suggestions to solve this? Here's a snippet of code that I use:

string path = Path.Combine(Application.streamingAssetsPath, "datafile");
        
if (path.Contains("://") || path.Contains(":///"))
{
    UnityWebRequest www = UnityWebRequest.Get(path);
    yield return www.SendWebRequest();
    // ... other error handling and sundry code here
}
Admin

403 error means it's trying to load a file that doesn't exist. Look at the request path of the request that returned 403, is that a file that should exist with your game?

Files names are case sensitive, see https://itch.io/docs/creators/html5#common-pitfalls for common errors people have.

(1 edit)

Thanks for the reply! I had a couple of errors, one causing an extraneous 403 error..as you mentioned, incorrect filename (i.e. missing file). In addition, the file I need to access existed, but I did find a bug in my code where I thought I was properly waiting for the web request to complete before acting on the data. I had a button that should have been set as disabled until the data was ready, but it was active in Unity.