Process assets on import

Hello! Forgive me if this is a common topic, but I could not find a relevant answer too easily here, nor anything in the docs.

I want to be able to parse, transform, and/or create assets from data that I upload to my PlayCanvas project.

For example, if I upload a PNG image asset, I want to be able to detect that import, and automatically create Materials for it based upon the PNG asset’s naming convention. As another example, perhaps I upload a glTF/GLB file, and I want to be able to parse extension data from it manually to generate any other arbitrary amount of new assets from it.

Is this kind of behavior supported in the PlayCanvas Editor? Is there an obvious part of the PlayCanvas API that I’m missing?

Edit:

Is AssetRegistry the right direction?

Editor-API would help you to programatically create assets and similar: https://github.com/playcanvas/editor-api

but I’m not sure it has any events on when the asset is imported … you might need to manually execute them / rescan all assets and process new ones perhaps.

1 Like

If this provides the direct ability to upload assets of my own choosing, then I can create a preprocessing layer to handle that behavior myself! This seems to do the trick, then. Thank you!

2 Likes

Looks like there could be a hook here:

https://github.com/playcanvas/editor-api/blob/main/docs/classes/Assets.md#defaultuploadcompletedcallback

2 Likes