Values in ActorComponent properties with Instanced and EditInlineNew keywords are not saved

BStbck
Wed, 08 Mar 2017 23:26:56 +0000
C++

I have a weird problem when using a UPROPERTY with the Instanced keyword in a custom ActorComponent.
There are several similar questions already, but I couldn’t find one for this specific problem.

Steps to reproduce (with an empty C++ project):

1. Create three UObjects with EditInlineNew, two of them inheriting from the first one.

UCLASS(Abstract, BlueprintType, Blueprintable, EditInlineNew)
class UCppTestObj : public UObject
{
	GENERATED_BODY()
};

UCLASS(BlueprintType, Blueprintable, EditInlineNew)
class UCppTestObj1 : public UCppTestObj
{
	GENERATED_BODY()
};

UCLASS(BlueprintType, Blueprintable, EditInlineNew)
class UCppTestObj2 : public UCppTestObj
{
	GENERATED_BODY()
};

2. Create an ActorComponent with a property marked as Instanced:

UCLASS()
class UCppTestComponent : public UActorComponent
{
	GENERATED_BODY()

protected:
	UPROPERTY(EditAnywhere, Instanced, Category = "Game")
	class UCppTestObj* MyObj;
};

3. Create an actor with this component:

UCLASS(Blueprintable, BlueprintType)
class ACppTestActor : public AActor
{
	GENERATED_BODY()

	ACppTestActor(const class FObjectInitializer& ObjectInitializer);

protected:
	UPROPERTY(VisibleAnywhere, Category = "Game")
	class UCppTestComponent* TestComponent;
};

ACppTestActor::ACppTestActor(const class FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	TestComponent = ObjectInitializer.CreateDefaultSubobject<UCppTestComponent>(this, "TestComponent");
}

4. Create Blueprint of ACppTestActor , set the property MyObj of the TestComponent to “Cpp Test Obj 1”.

5. Place the actor in a map and change the property on the instance to “Cpp Test Obj 2”.

6. Save the map, exit (or load another map) and load it again. The value on the placed actor will have returned to “Cpp Test Obj 1”.

Notes:

This has even weirder effects when the property in the component is a TArray, but I suspect it is the same underlying cause and this is the simplest example I could create.

When the component is placed inside a simple Actor Blueprint in the editor, the value cannot be changed at all on the instance.

When the property is placed directly in the actor instead of the component, everything works as expected (value can be changed and is saved correctly).

The functionality would be really useful to have, so I would be thankful for any tips in getting this to work.

6 posts - 5 participants