Is there a way to execute code only in debug?

As the title says, is there a way to execute certain part of the code only in debug, when you're running the game on your computer ?

I draw and print a bunch of info when running the game that make the console lag and it's a bit of a pain to comment every lines of code everytime I have to run the game on the Playdate.

I know I could just put the code between "if (inDebugMode) then" statement but I was asking for something similar to #if UNITY_DEBUG, directly integrated to the console if it exist.

I think #ifndef TARGET_PLAYDATE should do the trick.

I'm sorry I should have precised I code in LUA, not in C

ohh, well, in that case there's playdate.isSimulator. That variable is nil on device and 1 in the simulator

2 Likes