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 .
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.
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.
Greetings,
edit: I am at work and forgot to change the account, so dont be confused
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.