Download

How to create a custom editor/layout for an array

I have a struct that looks something like this:


USTRUCT()
struct GAME1_API FItem
{
	GENERATED_USTRUCT_BODY()

public:

	UPROPERTY(EditAnywhere)
	FName Name;

	UPROPERTY(EditAnywhere)
	TSubclassOf<AActor> Class;
};

And an array like so:


UPROPERTY(EditDefaultsOnly)
TArray<FItem> Units;

Which produce the following:
7be64b936a259db83f67148788cbf5872f14c1fe.jpeg

Would it be possible to make it looks something like this instead:
1f0f61000a3b5d7cdb437d8d800652063dde9ca0.jpeg

I have looked into it but I can’t make sense of it and I’m not even sure if it can be done.
There isn’t much documentation or information on the topic so if anyone could point me in the right direction, or even provide an example, I would appreciate it.

You need to look into details customization. There are heaps of examples in the engine code, in particular here. It’s not super straightforward though.

I’m not sure when it comes to customizing an array directly, I think you’d need to wrap it in a USTRUCT and customize that. Or customize the UCLASS that embeds your array, if you’re only going to be using it in one place.

Thanks, I’ve been through that but can’t figure it out.
It may also be outdated because the SArrayProperty that they mention doesn’t seem to exist. This person also couldn’t find it but never get an answer.

Yeah it’s definitely out of date. Looks like that has been replaced by FDetailArrayBuilder, see here for examples of using it.

Thanks, I’ll have a look.

@cmann were you able to use FDetailArrayBuilder? Can you post some example?

Unfortunately not - I had trouble figuring it out so eventually I gave up.

I didn’t take a look into the new 4.14 yet - but didn’t they introduce data maps exactly for that?

Good point - Maps and Sets should work perfectly for that.

It still would be nice to be able to customise though when you need more advanced functionality.