Tutorial: Pull Images from the Web in Unity WebGL



Downloading images from the web is a natural thing you might want to do in a WebGL game. But it’s not as straightforward as it should be! You get the dreaded CORS error (in WebGL only!)

This tutorial shows you how to use a service called Filestack that gets you around CORS errors to download images from the internet in Unity WebGL Builds.

Cool unity game? Upload it to: https://simmer.io

Github: https://github.com/TheRoccoB/UnityImageDemo

Filestack tool: https://filestack.com

Unity + WebGL Course: https://www.udemy.com/webgl-with-unity-the-ultimate-guide-to-games-in-the-browser/?couponCode=TENBUCKS (92% off!)

And here’s the error you might get (in case someone is googling around for this):

Access to XMLHttpRequest at ‘https://someurl.com’ from origin ‘http://localhost:60475’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource

or

RuntimeError: memory access out of bounds,RuntimeError: memory access out of bounds

source

Leave a Reply

Your email address will not be published. Required fields are marked *