Is there a way to load assets within the DOM while still in the PlayCanvas editor?
My example is a .ttf font file that I’m referencing in a CSS @font-family Entry. If I export my project, and upload it to my web-server, there is no issue; I can put a simple relative URL in the @font-family reference (like “media/fonts/myFont.ttf”), but I understand that the location of assets in the PlayCanvas editor are managed programmatically.
Is there a way, while still in the editor, to reference assets, like fonts, which have been imported into the editor, within DOM content? Is there a PlayCanvas class that can resolve an asset name or some other input with the Editor managed URL of the asset in question?
As fonts don’t get packaged with the published build, unfortunately it is no longer possible [SOLVED] How to use custom font (font icon) in the editor?
You will have to host it externally.
As images (jpg, pngs etc) are packaged with the publish build, you can use https://developer.playcanvas.com/en/api/pc.Asset.html#getFileUrl with DOMs/CSS via a string replace method during the ‘load’.
Surely you mean only if they’re not referenced by another script, right? I have published builds which have included fonts, but it’s done with an Element or some other text rendering script.
I just need to allow cross-domain access to my web-server and that should do it for now.
When you upload a TTF, it gets processed into a bitmap font with a mapping JSON. The TTF file itself is not packaged with the build.