Exposing static variables and functions via BlueprintFunctionLibrary in Unreal Engine 5 C++



Note: this is more of a workaround

// .h file

UCLASS()
class TESTING_API UMyBFL : public UBlueprintFunctionLibrary {
    GENERATED_BODY()

   public:
    UFUNCTION(BlueprintPure)
    static float GetMyConstant();

    UFUNCTION(BlueprintPure)
    static bool MyStaticFunction(int32 Arg1, int32 Arg2);
};


UCLASS()
class TESTING_API UMyObject : public UObject {
    GENERATED_BODY()

   public:
    static const float MY_CONSTANT;  // Exposing to blueprints via Function Library
    static bool MyStaticFunction(int32 Arg1, int32 Arg2) { return Arg1 == Arg2; }
};
// .cpp file

const float UMyObject::MY_CONSTANT = 10.5f;
float UMyBFL::GetMyConstant() { return UMyObject::MY_CONSTANT; }
bool UMyBFL::MyStaticFunction(int32 Arg1, int32 Arg2) { return UMyObject::MyStaticFunction(Arg1, Arg2); }