Debugging
This page will demonstrate how to debug TypeScript code for Genies Experiences.
Logging in TypeScript
You can use the console methods to write to Unity's console, like so:
console.log(`log : Hello World`);
console.warn(`warn : Hello World`);
console.error(`error : Hello World`);
You can also use Unity's Debug
class by importing it.
Debugging with VS Code
It is recommended to use VS Code as your IDE because it is easy to use, has helpful extensions, and supports debugging in Unity.
Read the VS Code page for more information on how to get started.
Enable Debugging
In Unity, select the top menu dropdown Genies > Scripting > Enable Debugging option.
Select the Debugging Profile
In VS Code, open the left side Run and Debug tab. Set the debugging profile at the top to Genies Local Script Debugger.
Add Breakpoints
Click to the left of the line numbers to add a breakpoint on a specific line which appears as a red dot.
Enable Debug Mode
In the bottom right corner of the Unity window, click the bug icon to enable Debug Mode.
Attach the Debugger
In Unity, enter Play mode. The Game window should display "Attach Debugger!"
. Go back to VS Code and press the green Start Debugging button. The debugging information will appear for each breakpoint.