I cannot find documentation to access button through script. I am trying to use active = false to set the button to deactive state. How do I achieve this?
var ButtonScript= pc.createScript('buttonScript');
ButtonScript.attributes.add('myButton', { type: 'entity' });
so basically myButton.active = false. I do not want the entity to be deactive, instead button attached on entity should be deactive.
Loop through an array of stated entity attributes.
var MyScript = pc.createScript('myScript');
MyScript.attributes.add('ENTITY_ARRAY', {
type: 'entity',
array: true,
default: ['', '']
});
MyScript.prototype.update = function (dt) {
for (var i = 0; i < this.ENTITY_ARRAY.length; i++) {
this.ENTITY_ARRAY[i].button.active = false;
}
};
In my code I only stated two entity slots but you can easily add more by adding more ā ā to the default attributes code section for ENTITY_ARRAY.
Please note that if you re-parse after changing your default list slots amount you are going to need to re-state your entities in the Editor. So make sure that you have a rough idea of the right amount of button entities that you are going to be using.
I personally prefer to use the use input when disabling a button I would use something like this to go through an array.
for (let i = 0; i < myarray.length; i++) {
let entity = myarray[i];
entity.element.useinput=false;
}