One way that I approach that is by using a global state variable in my UI button script. For example:
var ButtonLogic = pc.createScript('buttonLogic');
ButtonLogic.hasFocus = false;
// initialize code called once per entity
ButtonLogic.prototype.initialize = function() {
this.entity.button.on('mouseenter', () => ButtonLogic.hasFocus = true);
this.entity.button.on('mouseleave', () => ButtonLogic.hasFocus = false);
};
Now in your camera input script you can check on top if any button has input like this, and if it’s true cancel/bypass any input:
if(ButtonLogic.hasFocus) return;
// --- camera input