How can I reference an image from the Assets folder in the loading screen?

I believe this was asked before and the answer was to use a base64 image. While this works, it’s extremely cumbersome because the code becomes difficult to navigate. The base64 image takes hundreds of lines. Unity has a special folder called StreamingAssets that is easily accessible using a custom webgl template. The StreamingAssets folder ends up at the root of the final build, as a sibiling of the index.html.

Doesn’t PlayCanvas have something like this? If not, would it be better if I created a feature request for this? I just want to reference a local image in the loading screen script, using a base64 image is too cumbersome.

Hi @Marks,

Check this post, it may be what you are looking for:

Unfortunately, not exactly. The issue with Yaustar’s solution to get the file when preload starts, is that the file doesn’t show up immediately when the page loads. It kind of defeats the purpose of the loading screen in the first place. What is really necessary here is a special folder like Unity has(StreamingAssets) that is a sibiling of the index.html, that I could reference in the loading screen script. Then I could reference the file instead of using base64 or instead of waiting for the preload.

I’m going for a feature request here. Thanks Leonidas.

1 Like

I’ve done a variant of this here where it waits for the asset to be added to the assets registry and sets the source of the image: https://playcanvas.com/project/971641/overview/loading-screen-from-assets

As mentioned on Discord, this is not recommended because:

You can but you shouldn’t. The recommended practise is to use a base64 url or external hosted images.

This is be a use you don’t have control of the loading order of the assets during the preload. The image may not be loaded until halfway, near the end of the preload so you can’t guarantee when the user sees the loading image.

2 Likes

You can add the B64 image string to the bottom of the file if that’s the only issue.

eg https://playcanvas.com/project/971646/overview/base64-at-the-end-of-file

1 Like

I added an issue here.

You can add the B64 image string to the bottom of the file if that’s the only issue.

Thanks Yaustar, this helps. However, I still think it would be nice to have a special folder that can be accessed from the loading script.