requiring a blueprint to override a c++ function


I have an abstract class similar to this:

class MyComponent : public UComponent
int GetANumber();

Is there to make any blueprint that inherits from this C++ class to fail to compile unless it overrides GetANumber()? Essentially a pure virtual function?

The best I got so far was to change the function to BlueprintNativeEvent, and in the C++ implementation of this function, throw an assert. Less than ideal since it moves something that should be able to be detected at compile time to run time.

I don’t know how to trigger a blueprint compilation error, but you could check if the BP function exists in your class PostLoad or some other initialization function. If you check the code that is added to the generated files for the BlueprintNativeEvent you can that it does exactly that to see if it should call the BP or native implementation.