Exposing Static Constant to Blueprint in Unreal Engine C++



Note: this is more of a workaround

// ExampleObject.h file

UCLASS()
class MYPROJECT_API UExampleStatic : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()

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


UCLASS()
class MYPROJECT_API UExampleObject : public UObject {
    GENERATED_BODY()
    
    public:
      static const float MY_CONSTANT;  // Exposing to blueprints via Function Library

};
// ExampleObject.cpp file

const float UExampleObject::MY_CONSTANT = 10.5f;

float UExampleStatic::GetMyConstant(){ return UExampleObject::MY_CONSTANT; }