I’m rather new to PlayCanvas and therefore sometimes having troubles to know what is the best way to do something.
Now I have this script to load an asset:
LoadGlbAsset.prototype.initialize = function() {
utils.loadGlbContainerFromAsset(this.glbAsset, null, this.glbAsset.name, function (err, asset) {
if (err) {
console.error(err);
return;
}
var renderRootEntity = asset.resource.instantiateRenderEntity();
this.entity.addChild(renderRootEntity);
}.bind(this));
};
It is attached to an entity for which the asset has to be loaded.
An other script on the same entity has to search for some specific childs. Before I can start searching I have to wait unit the asset is loaded. What is the best way to do this?
A: the callback above could call a function in the other script. Seems not so elegant to me.
B: merging the two scripts so that I can do the search in the callback. Also no so elegant.
C: using events?
D: other ways?