I’m using the onAttributeChanged function in my script and it doesn’t seem to ever fire. I have it in multiple scripts and it doesn’t fire in any of them. It just never seems to get called so I assume I’m doing something wrong. I also want to know how the values are changing from the launcher so I’m updating them in the browser.
At the top.
pc.script.attribute('cameraBoomLength', 'number', 30, {
displayName: "Camera Boom Length"
});
In the initialize function of my script I have.
this.on('set', this.onAttributeChanged, this);
And in onAttributeChanged
onAttributeChanged: function (name, oldValue, newValue)
{
console.log('tiCameraBoom: onAttributeChanged called.');
if (name === 'cameraBoomLength')
{
console.log("name is: " + name);
var tLoc = this.tiCamera.getLocalPosition();
this.tiCamera.setLocalPosition(tLoc.x, newValue, tLoc.z);
}
//this.updateTiCameraBoom();
},
All the entities are set up correctly, if I move the code to a function I call myself it works find. I just thought this automatically fired off when editor attributes were changed. I’m just wondering if I’m doing something wrong. Any help would be greatly appreciated.