I’m trying to enable and disable an entity using a button.
I’ve attached a script to the button which includes the declared a script attribute as the target entity (contentPanel) I want to enable and disable.
Currently it launched with the contentPanel being disabled. But if I click the button with the script, it does not work.
“Uncaught TypeError: Cannot read properties of undefined (reading ‘enabled’).”
var ButtonEntityActive = pc.createScript('buttonEntityActive');
ButtonEntityActive.attributes.add('contentPanel', {type: 'entity', description: 'The entity that needs to be activated/deactivated'});
// initialize code called once per entity
ButtonEntityActive.prototype.initialize = function() {
this.contentPanel.enabled = false;
this.entity.button.on('click', function(event) {
this.contentPanel.enabled = true;
});
};