When I creat a BlueprintNativeEvent or BlueprintImplementableEvent
void TestFunction(FString Str);
then I compile, I always get a error says that cant find the overloaded function TestFunction( const FString& Str )
when I look into the Project.generated.cpp file,
I saw my function become TestFunction( const FString& Str );
however, if I manually change the generated.h file to TestFunction( FString Str ) and build again, the build succeeded;
but if I change some thing in code and build again the problem appears again.
I suppose compiler wants you to declare event with const FString& Str instead of FString Str, possibly because you can’t modify FString and you should declare it as not modifiable.
What I mean is there are a several ways to use arguments:
- FString Str - receiving string as argument to this function. Used to transfer string from blueprint to C++ function.
- FString& Str - returning string by assigning value to this argument (works almost as pointer). Good for returning several values at once.
- const FString& Str - gets string by with guarantee that we cannot modify it. Blueprint treats it as returned. Used to output string from C++ to blueprint.
Your case is the third.
And don’t ever modify generated files. They are not supposed to be modified, they generated by header tool and any little change can create huge problems.
Have a look here: https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Functions/Specifiers/BlueprintNativeEvent/index.html
According to the documentation you need to “Provide a body named [FunctionName]_Implementation instead of [FunctionName]”.
Thank you so much!