[SOLVED] Add asset to script attributes programmatically

how to assign asset material to slot in script attributes?

I mean I did

for(var i = 1; i < 59; i++){
    C1.attributes.add('sign' + i, {type:'asset', assetType: 'material'});
}

the slots are empty so what is the way alternative to drag&drop to assign?
or I must drag&drop 58 times?
ok I think I must assign to asset.resource
but how to find the signs from sign1 to sign58 in asset registry?
ok the .filter
https://developer.playcanvas.com/en/api/pc.AssetRegistry.html#filter

but have issues with
this.‘sign’ + i

how to make it like
this.sign1.resource
this.sign2.resource

?

To set attribute values to a script instance in code you do something like this:

myEntity.script.scriptName.attributeName = myAsset;

// for example to change an attr on the orbit-camera.js script
myCamera.script.orbitCamera.distance = 13;
2 Likes