You can get an instance for function libs, it’s the class default object.
I also tried various attempts at creating an intermediate C++ BFL with an override-able/implementable BP function, but no luck so far.
A simpler way would be to turn functions into member functions, and provide an accessor. No need to manage an instance since there’s already the CDO. You just need a variable somewhere to hold a reference to the BP version of the lib.
For example
UCLASS(Blueprintable, Abstract)
class UBFL_Test : public UObject
{
GENERATED_BODY()
UPROPERTY()
UClass* BpLibClass;
UBFL_Test()
{
static ConstructorHelpers::FClassFinder<ThisClass> BpLibAsset(TEXT("/Game/BP_BFL_Test"));
if (BpLibAsset.Succeeded())
{
BpLibClass = BpLibAsset.Class;
}
}
public:
UFUNCTION(BlueprintPure)
static ThisClass* Get() { return BpLibClass->GetDefaultObject<ThisClass>(); }
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void PublicMethod();
};
The referenced asset at /Game/BP_BFL_Test would be a blueprint child class of UBFL_Test which implements the methods.
Of course it would be better to reference it in a BP-assignable variable such as in a GameInstance subclass. FClassFinder is more of a prototyping temporary solution.
You could even make a wrapper for each function to make it entirely transparent for the blueprints side, but that might get quickly cumbersome, like so
UFUNCTION(BlueprintImplementableEvent) //not callable
void PublicMethodImpl();
UFUNCTION(BlueprintCallable)
static void PublicMethod() { return Get()->PublicMethodImpl(); }