When I try to apply changes from an instance of an Actor Blueprint to the original Blueprint in the editor (by clicking “Apply Instance Changes to Blueprint”), any modified Instanced Struct Properties are reset to None in both the instance and the original Blueprint.
I’ve isolated the problem with a single Actor class:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "StructUtils/InstancedStruct.h"
#include "MyActor.generated.h"
UCLASS(Blueprintable)
class PLUGINDEV_API AMyActor : public AActor
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere)
TInstancedStruct<FTransform> TransformStruct;
AMyActor();
};
Changes to regular struct properties on an Actor instance will be correctly saved to the original Blueprint, however if the struct contains either an instanced object or instanced struct then the entire struct will fail to update correctly.
The following code shows the cases where applying the instance changes does and does not work correctly:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "StructUtils/InstancedStruct.h"
#include "MyActor.generated.h"
//Test instanced object class
UCLASS(Blueprintable, EditInlineNew)
class PLUGINDEV_API UMyInstancedObject: public UObject
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere)
int Property = 0;
};
//Struct that works because it has no instanced properties inside
USTRUCT(BlueprintType)
struct FMyStruct
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere)
int Property = 0;
};
//Struct that does not work because it has instanced properties inside
USTRUCT(BlueprintType)
struct FMyStructWithAnInstancedObjectProperty
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere)
int Property = 0;
//Even if this property is not modified, its presence in the struct will prevent the entire struct from having its changes applied to the original Blueprint
UPROPERTY(EditAnywhere, Instanced)
UMyInstancedObject* MyObject;
};
//Main Actor class being instanced and modified in the Editor
UCLASS(Blueprintable)
class PLUGINDEV_API AMyActor : public AActor
{
GENERATED_BODY()
public:
//Trying to apply changes to this will reset the property to 'None'
UPROPERTY(EditAnywhere)
TInstancedStruct<FTransform> TransformStruct;
//Trying to apply changes to this just fails (Editor popup says "No properties were copied")
UPROPERTY(EditAnywhere, Instanced)
UMyInstancedObject* MyObject;
//This works fine
UPROPERTY(EditAnywhere)
FMyStruct MyStruct;
//This does not work because it has instanced properties inside
UPROPERTY(EditAnywhere)
FMyStructWithAnInstancedObjectProperty MyStructWithAnInstancedObjectProperty;
AMyActor();
};
EDIT:
After digging around it seems like the problem is in EditorUtilities::CopyActorProperties. I can call the function to copy most of the properties between two Blueprints, however it doesn’t copy instanced properties.
I’m guessing this is a bug or unsupported feature, but if there are any ways to solve without modifying the engine I’d appreciate it.