Load files from filesystem (GET Request)

I have a qestion about loading files from a folder in a project.
I’m building a HTML ui in PlayCanvas at the momen and a lot of the ui elements have images.
This images are in a folder root/ui/image/myImage.png
I want to load this images within my ui, using the image tag <img src="pathToImage/myImage.png" />
How do I get the path to the imagefolder to access all images?

Hi @Patrick_Munster,

You will have to use some Javascript to read the asset url and update the HTML dynamically on run time. You can use the following method to get the url:

var assetUrl = myAsset.getFileUrl();

Just note that this isn’t the same url when running through the editor vs when running from a published build.

https://developer.playcanvas.com/en/api/pc.Asset.html#getFileUrl

1 Like

Thank you very much!
This will work for me.
I just hoped that there is a way to make the URL somehow static to disconnect the ui development from the rest of PlayCanvas.

Mmm, good question, but not sure there is currently a way to do that.

Given assets are easy to update/change their urls e.g. when forking a project.