The "Instanced" flag for UPROPERTY

Thank you so much for the detailed explanation!

I had an issue as well with Instanced objects contained in a TArray and saw constant crashes. This is how my simple example looked like.

UCLASS(Abstract, EditInlineNew)
class UMyClass : public UObject
{
  GENERATED_BODY()
	
  UPROPERTY(EditAnywhere, Category = "Dont|Crash")
  uint8 ValueBase;
};

UCLASS()
class UMyClassChild : public UMyClass
{
  GENERATED_BODY()

  UPROPERTY(EditAnywhere, Category = "Dont|Crash")
  uint8 ValueChild;
};

UCLASS()
class SOME_API USomeClass : public UObject
{
  GENERATED_BODY()

  UPROPERTY(Instanced, EditDefaultsOnly, Category = "Dont|Crash")
  TArray<TObjectPtr<UMyClass>> Array;
}

It seems to be that this is an uncovered use case. If I change the Category for the Array to something that is not “Dont|Crash”, then I don’t see any crashes. :muscle:

Or change the categories of your instanced class members. :wink:

EDIT:
It seems to work if you don’t use sub categories with |. Also I saw some weird object editor properties that are not contained in the instanced objects. I don’t recommend using the exact same sub categories like your own object (actor, actor component …).

2 Likes