Static Function in C++ Used in Blueprint

I’ve encountered weird circumstances lately. I’ve created a class in C++ and applied UCLASS macro on it. Inside this class, I created 5 static functions. All of these functions are UFUNCTION(BlueprintCallable, Category = "Helper"). I’m able to use them properly in Blueprint (event graph and macros). It runs fine when I play it in PIE.

But whenever I created the sixth static function in C++ and also use UFUNCTION(BlueprintCallable, Category = "Helper"), the Editor became unstable. Sometime it can appear normally like the other 5, in event graph and macro. But when I closed the UE editor and reload it, it show compilation error and the sixth function is undetected. I could easily close the UE editor, change the function name, rebuild the whole project in VS, and then reopen UE editor. It will then show this new function. I can use this function again normally. But it if I close the UE editor and reopen it, the same error keeps happening.

It seems like, the compiled static function in C++ is only available upon hot reload. But will be gone when the editor close. No matter how much I recompile or rebuild in VS, that function will be disregarded by UE editor. The only way to have UE editor recognize the sixth static function is by renaming it and recompile the source code. But it is only temporary upon hot reload. It’ll be gone again, after the UE editor closes.

Here’s an example of one of the static function (created in C++, but used in blueprint).

It is used to convert FColor structure to FLinearColor structure.

Is there some framework rule that I’m not aware of or is this a bug in UE editor?

This looks like hot reload bugging out which is quite known problem, check if compiling while editor is closed makes things more stable.

Hey Pelangi,

I agree with that this does sound like a hot reload issue. Give his suggestion a try and let us know if that helps at all. If not, we can continue to investigate.

Thanks

So I don’t know the root cause and how to properly solve it. So I just created a fresh new project and then re-copy the source code + content files from the original project to this new one. I rebuild everything, made some adjustments to project settings (like the original one), and everything went well.

I can now add lots of static functions in C++ and use them in Blueprint without any problem. Thanks guys for your clarification.