onAttributeChanged for asset attributes

Hey guys,
I have a small question regarding the “onAttributeChanged” function.
I am using that quite a lot to detect, if things in the editor got updated to automatically apply these changes in the play window. So handy without the need to hammer f5 :heart_eyes: .

That’s works all fine, when I update things like Booleans, or strings, but not on script attributes of the type “asset”. These don’t toggle the function at all, is that on purpose or a bug?

Might there be another way to detect a change of whose, except checking the length of the asset in an update loop? (Want to get rid of exactly that, to optimize the script a bit)




I’m trying to reproduce this maybe you can help me out. I have a script with an asset script attribute and the onAttributeChanged method like so:

pc.script.attribute('texture', 'asset', null, {
    type: 'texture',
    max: 1

pc.script.create('test', function (app) {
    // Creates a new Test instance
    var Test = function (entity) {
        this.entity = entity;

    Test.prototype = {
        onAttributeChanged: function (name, oldValue, newValue) {
            console.log(name, oldValue, newValue);    

    return Test;

Then I launch the application from the Editor and look at the console. I assign different textures to the ‘texture’ script attribute from the Editor and looking at my console I see the onAttributeChanged function being called.

Perhaps I’m doing something different than you?

Hey vaios,
the code is more or less the same, the only difference is ,that I am using css and html asset types and haven’t defined max 1.

I quickly tested that in a separate project and exactly that seems to be the issue. If I add max 1 to the attribute definition the change function gets called, without it not.


edit: I am at work and forgot to change the account, so dont be confused :smiley:

Looks like lists of assets don’t work properly indeed. I’ll log it as a bug and will fix as soon as possible - thanks and sorry for the inconvenience :smiley:

No problem, wasn’t any inconvenience yet.
I was only a little bit confused on the weekend, why it wasn’t working :stuck_out_tongue:

and thanks a lot for looking into this so quickly again.


Hey @vaios,

is there any update on this issue?

I’m using the “attr” event to check for updated inspector attributes, as described in the updated docs in combination with a string array attribute
AnyScript.attributes.add("someStrings",{ type: 'string', default: ['Lorum','Ipsum'], array: true, title: "Strings: ", description: "A String Array."});
and I’m experiencing the same issue,
if I delete or add new array members to the attribute the “attr” event is not triggered, while any other single value attribute does trigger the event.