Search code examples
airconsole

How to debug AirConsole Unity quick example


I've followed the instructions on http://developers.airconsole.com/#/guides/unity and I am able to start with and without debug view, but it seems that no messages are sent at all (the OnMessage method in the MonoBehaviour class is never called). Is there a way to debug this problem?


Solution

  • You can debug the controller by adding console.logs to your controller.html.

    Let's assume you have a button element on your controller that calls myButtonFunction.

    <button id = "myButton" ontouchstart="myButtonFunction()">Send A Message to Screen</button>  
    

    Then you add a log to the function to see if the button pressing works correctly.

    var myButtonFunction = function() {
           console.log("myButton was pressed");
           airconsole.message(AirConsole.SCREEN, "button-pressed");
    };
    

    To see what your controller logs, you need to use the Start Mode 'Virtual Controllers' and open your browser's developer console.