BP equivalent for #if UE_BUILD_SHIPPING

Hey there,

In C++, we may write the following:

#if !UE_BUILD_SHIPPING
   // lalala
#endif 

Is there an equivalent node for blueprints? Or how can we determine if a game is in shipping/debug/test mode??

It’s an older question, but I managed to solve it this way:

But, this “Get Build Configuration” node does not exist, you’ll need to create a C++ class (parent: blueprint function) and add the following code to it (the following code is my code, change your (function) names accordingly)

GetBuildConfiguration.h

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "GetBuildConfiguration.generated.h"

/**
 * 
 */
UCLASS()
class SPEEDRUNNER_API UGetBuildConfiguration : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

		UFUNCTION(Category = "Utility", BlueprintCallable)

		// Return to blueprint node
		static void GetBuildConfiguration(FString& Configuration);

};

GetBuildConfiguration.cpp

#include "GetBuildConfiguration.h"

void UGetBuildConfiguration::GetBuildConfiguration(FString& Configuration)
{

#if !UE_BUILD_SHIPPING
#if WITH_EDITOR
	Configuration = "TEST";
#else
	Configuration = "DEVELOPMENT";
#endif // WITH_EDITOR
#else
	Configuration = "SHIPPING";
#endif
}
3 Likes

Still no built in BP node for this ? Strange…
How are we supposed to manage this ?

For example in my case I have variable for dev only. How to be sure they won’t be used in shipping ?

Update Q4 2023

There is now a Blueprint node called Get Build Configuration (from UKismetSystemLibrary).

But, it’s still probably better to do things in C++ with the macros (UE_BUILD_SHIPPING for example) since that way you can strip away code at compile-time. This has several benefits:

  • Size of the output assembly: Code inside #if ... #endif gets ignored by the compiler. So less code is generated.
  • memory usage: Fewer classes get created because they were ignored by the compiler, so less memory allocations.
  • runtime efficiency: Less code was generated, so less code will run when people play the game. Less CPU work = faster program!
  • code safety: Code not indended for shipping usage does not exist in shipped builds, so the compiler will tell you (during compilation) if you call code that does not exist when making a shipped build. So it’s impossible for the user to somehow trigger that code to run.

It’s a very common thing when building games to use these, commonly for logging and error handling, but also for disabling tools that are only needed during development.

2 Likes