Blueprint compiler directive (such as #if, #ifdef)

Hi all,

Does anyone know how to create compiler directives in blueprints? I would like to create a macro to report on specific points of the execution but I don’t want to have to go back and remove all these dev specific flows for the packaged version, so I hoped to create a constant “InDevelopment” or something and if that is true the macro includes the reporting flow, otherwise it passes through. Does that make sense?

Thanks in advance for the help.

Best regards,
Alessandro

Hi Alessandro,
if you use Print Strings to write to the screen/log, they will be automatically stripped out if you package your game for Shipping. Would that work for you?
Cheers,
Marco

Hi Marco,

Many thanks for the note. Yes indeed, but unfortunately some of the reporting through printstring requires loops to get all elements of certain arrays, so in the packaged version the loop will run and will skip only the actual printstring node, which might have a small but unnecessary hit on performance. It would be great if there was something like a devif node with two outputs, A and B, that if in development would execute A and B in sequence, and if in production it would only execute B. Do you know if there is something like that?

Many thanks again for the help.

Best,
Alessandro

How about defining a bDebug variable in your GameInstance (so it is “global” to the game) and use it to drive a Branch which, if false, will skip all the debug related code?

Hi Marco,

Yes, good idea. It still causes a minor drag but I agree it would be minimal as it’s just a single instruction to skip the whole code.

Building on your idea I implemented a macro node that has the two exec outputs, A and B, and it is set to execute A and B in sequence but when I ship I will just edit that macro to skip the sequence and go straight to B, so it will cause no drag and will require absolutely no change to the code from dev to production.

Thanks again for the help!

Best,
Alessandro

Hello there!

Maybe 2 years late but I found this entry because I was looking for something similar to use in Blueprints.

You could use the pure function called “isPackagedforDistribution” to achieve what you are looking for.
Link: Is Packaged for Distribution | Unreal Engine Documentation

cheers!