gameatp
December 22, 2025, 8:17am
1
Hi everyone,
I’m working on a PlayCanvas project where I instantiate entities from Templates using template.resource.instantiate(), then add the instantiated entity to the scene.
Hi @gameatp !
Below some topics related to your question.
I’m trying to figure out if theres a way to know when all dependencies (children) of a template asset are loaded as I want to instantiate it to the scene.
Using asset.ready doesnt work since it seems to fire as soon as the parent asset is loaded without waiting for the rest.
var self = this;
var onAssetsLoaded = function(asset)
{
let go = self.prefab.resource.instantiate();
go.setPosition(0, 0, 0);
self.app.root.addChild(go);
};
self.prefab.ready(onAssetsLoaded);
th…
I have a large number of templates that I need to load at runtime to cut down on load times. My code to ensure that I have all assets before using them looks like this:
Global.prototype.ensureAssetsLoaded = function(toLoad, callback, callbackScope) {
let assetCount = toLoad.length;
let assetsLoaded = 0;
let onLoad = function(asset, assetCategory, assetCode) {
console.log('loaded '+assetCategory+'.'+assetCode);
assetsLoaded++;
if (assetsLoaded >= asse…