Using a C++ struct in blueprint and hot reload

It seems that you can’t use a c++ struct in blueprints when using hot reload.

If I have a BlueprintType struct and use it in a blueprint, whenever I do a hot reload, I get a error when compiling/saving the blueprint about it having a link to a private object in a external package and will not save the blueprint. The only way to fix this seems to be to close and reopen the editor.

The error mesage when saving blueprint is:

Can’t save
C:/Users/Main/Documents/Unreal
Projects/LogicTesting/Content/Blueprints/LogicBlueprint.uasset:
Graph is linked to private object(s)
in an external package. External
Object(s): HOTRELOADED_LogicActor_0
/Engine/Transient

Try to find the
chain of references to that object
(may take some time)?

I have the same problem right now on Engine Version 4.8. Is there a solution for this issue?

I moved question to bug raports as i think it’s more appropriate and someone from epic might address this issue as a bug.

In general hot reload does not like changes in external linking configuration (and you do that by modifying header files) so there no 100% guaranty that hot reload will always work properly

Hi MattW and ,

This issue looks very similar to another issue involving structs and hot reloading that I submitted a report about recently (UE-20475). Would either of you be able to provide some additional information about how you have set up your struct (the code for this would be great) and how you are using it in your Blueprints?

Hi ,
so my struct look like this:

USTRUCT(BlueprintType)
struct FActionData
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Data")
	ECommandAction Action;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Data")
	FVector Point;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Data")
	AUnit* Unit;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Data")
	AActor* Actor;

	FActionData();

	FActionData(ECommandAction action);

	FActionData(FVector point);

	FActionData(AUnit* unit);

	FActionData(AActor* actor);
};

When i change something on AUnit the struct breaks in blueprint. Refreshing the nodes or again hot reload doesn’t help in this case. Only a full recompiled project will work again.

Here is a screenshot how i use the struct (everything works fine):

And this is how it looks like when i hot reload after i changed something in AUnit:

Now I have to close the editor that it works again.

I think the problem are references in structs to own classes.

Hi ,

Sorry, I dropped the ball on this one. Using the information you provided, I was able to get some errors in a Blueprint when performing a hot reload. However, none of the errors that I received were the same as the one mentioned in the original post. Here’s what I did:

I created a new custom code class derived from Actor and named it MyActor. In this class I created a new struct:

USTRUCT(BlueprintType)
struct FActionData
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Data")
	FVector Point;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Data")
	AMyActor* Unit;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Data")
	AActor* Actor;
};

Then I added a member of that struct type to the class.

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "TestCat")
FActionData TheData;

I then opened the project in the Editor and made a Blueprint of the class. I created the following setup in the Blueprint’s Event Graph:

I then added a new UPROPERTY to the class in code and performed a hot reload. This gave me the following results when I tried to compile the Blueprint after the hot reload:

Closing and reopening the project showed the connections between the Make, Set, and Break nodes had disappeared. Reattaching those connections let me compile the Blueprint successfully. Does this match what you were seeing. In particular, are the error messages in the Blueprint the same as the ones that you were seeing?

Edit: I should note that I did not see any errors specific to saving the Blueprint.

That is the same error i have.
When i hot reload my project and i get errors in my log, i do not open the blueprint so i don’t lose any connections between the nodes. The connections only disappear when i open the blueprint.

Thank you for the confirmation. I have submitted a report of my observations to have this issue investigated further (UE-21144).

One thing I did notice after I posted yesterday is that the broken connections seemed to only occur in 4.8.3. In 4.9.1 and our latest internal build, the connections did not break if the Blueprint was opened prior to closing and re-opening the Editor.