Unreal Blueprint variable only appears after hot recompile

Hi all

I’m seeing some weird behavior regarding passing variables between blueprints and C++. The situation is that I have a parent class “DisplayTextHudActor2” declared in C++. This class inherits from AActor, and has a public property declared as follows:

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="SomeCategory")
	bool ShouldDisplaySickText = false;

I have a blueprint object that is a child of DispalyTextHudActor2. This blueprint reads the ShouldDisplaySickText variable and does stuff with it. When I start the unreal engine, the variable is listed as undefined:

201351-missingvar.png

This prevents the blueprint from compiling and the game from running. When I rebuild the c++ project via Visual Studio, after the binaries are hot reloaded the issue goes away, and everything works as expected. That is, until I go to package the project.

When I try to package the project for Windows (32 or 64 bit), the cooking script fails with the same error ("Could not find a variable named "ShouldDisplaySickText in ‘DisplayTextInterface_C’).

However, I have noticed that if I start the unreal editor via Visual Studio, then the variable is always defined, and I can export the project. However, this prevents me from modifying any of my C++ code (as the game is “running”), so it breaks the workflow. For reference, I am building in the “DebugGame_Editor” configuration.

How do I pass variables between C++ and blueprints so that I can export the project without having to start the Unreal Editor from Visual Studio?