BlueprintAutocast in C++ UBlueprintFunctionLibrary Subclass

Another solution (for people with a similar problem): in my case it worked after setting the functions as public.
I forgot that because I was copying it from Epic’s code. Interestingly, theirs worked without being public.
And I found this on EdGraphSchema_K2.cpp:


static bool IsAutocastFunction(const UFunction* Function)
{
    const FName BlueprintAutocast(TEXT("BlueprintAutocast"));
    return Function
        && Function->HasMetaData(BlueprintAutocast)
        && Function->HasAllFunctionFlags(FUNC_Static | FUNC_Native | FUNC_Public | FUNC_BlueprintPure)
        && Function->GetReturnProperty()
        && GetFirstInputProperty(Function);
}

This means it’ll only consider a function as an auto-cast if all of these are true:

  • it has the meta BlueprintAutocast
  • it’s static
  • it’s native (C++, so it’s always true)
  • it’s public
  • it’s BlueprintPure.
  • it returns something
  • it has an input parameter

That’s how I solved my problem. Hope it helps someone.

Edit 2023/08/23: make it more detailed

4 Likes