Debug flag accessible from code?

Hello,

If we wanted to do special code based on the debug flag (accessible using play button in editor), do we have access to its value in the scripts?

thanks

Hi @memleak,

The debug flag I think is loading the debug build of the PlayCanvas engine instead of the production.

I don’t think you can use #ifdefs in the code editor since there isn’t any preprocess step to remove them.

Of course you can check for the presence of the debug=true url param with regular JS and adapt your code accordingly:

const searchParams = new URLSearchParams(window.location.search);

if(searchParams.get('debug') === 'true'){
   // debug mode is on
}
1 Like

exactly what I needed! Thank you!