How to create new objects for an array in the default class options?

I have a custom class that derives off UObject (called card) and in my pawn class i have a TArray. In the blueprint derived off the custom pawn i want to create new object in the array in the default class options so the pawn will be created with the cards I created. How do i accomplish this? Right now all it gives me is the option to add more elements with a drop down menu with nothing in it (i assume its looking for objects to attach to the element)

This is my array:

UPROPERTY(EditAnywhere)
TArray<UCard*> StartingCards;

Because you probably use object pointer, which can hold only already instantiated object and in default you can set only objects that is already on the level in editor. Instead you need to hold class refrences which then you can spawn in to the world, to do that you need to use UClass* type

TArray<UClass*> StartingCards;

or if you want to limit possible selection in default menus to specific subclass (for example cards classes) you can use TSubclassOf, it the same as UClass* just limits selection

TArray<TSubclassOf<ACard>> StartingCards;

Then based of that array, you spawn the starting cards :slight_smile:

So I tried this method and it doesn’t work in the way I expected it to (it just gave me the option to create a blueprint based on the class I selected). Really what i’m trying to do is have it work as if the class was a struct and add a new element and be able to configure all the class variables for the element as if it was an array of structs

There no way to do that currently, only struct can be displayed like that. You will need to create a struct with initial data which you gonna apply to spawned object or existing object if you want

is there a way to do CanEditChange() on a struct?

This can be done, you need to make two additions to the specifiers as follows:

// Your UCard class declaration, add EditInlineNew
UCLASS(EditInlineNew [, anything else you need])
class UCard ...

// The propert, add Instanced
UPROPERTY(EditAnywhere, Instanced)
TArray<UCard*> StartingCards;

that worked!! Thanks