We all know that you can launch the inspector using strg+alt+i, but I am right now trying to add a button to my user interface that does the same thing:
function customEnterInspector () {
var scene = document.querySelector('a-scene');
if (scene) {
if (scene.hasLoaded) {
this.injectInspector();
} else {
scene.addEventListener('loaded', this.injectInspector());
}
}
}
$( "#intoinspector" ).click(function() {
customEnterInspector();
});
However, I do get the error:
Uncaught TypeError: this.injectInspector is not a function
at customEnterInspector (index.html:925)
at HTMLAnchorElement.<anonymous> (index.html:933)
at HTMLAnchorElement.dispatch (jquery-3.1.1.min.js:3)
at HTMLAnchorElement.q.handle (jquery-3.1.1.min.js:3)
I suppose the element (a-scene) that I am referencing is not the right one. I already tried with "window", but that didn't work either. Any advice on what I could else try?
Thanks & Best, - Max
foo.addListener('event', callback())will not work, becausecallback()is called immediately, not passed to the listener. Instead, you'll wantfoo.addListener('event', callback), which just hands the function to the listener so that it can be called later. Adding()makes the function run immediately, which we don't want. More details. - Don McCurdy