Dynamic struct polymorphism in BP, dropdown of variables declared in CPP

Hi! I have two different questions regarding the creation of neat little systems between CPP and BP.

  1. In Unity we can use SerializeReference to allow for polymorphism inside the editor. So, for example, I can have an AbilityBehaviour base class and multiple child classes. In an AbilityBehaviour field, I can then choose which behaviour to use, and the editor will now display custom data. This would mean in BP that I don’t need to create a new child BP class and populate data like StatusEffect and Duration for every usage of ApplyStatusEffect, I can have a single generic ApplyStatusEffect behaviour and always cutomize the fields on the fly.

image

image

  1. In GAS, you have dropdowns to pick an attribute that you have declared in CPP. This sounds like some crazy reflection magic to me, but it’s super useful. The alternative would be creating enums, ew. Is there a way to easily replicate this feature for my own systems, or does it involve some crazy backend engine modifications?

image

Thanks a lot!

Afaik this is not possible with structs, because TArray requires known fixed size, and pointers (other than objects) are not supported.

However you can do this with UObjects. It requires a combination of Instanced and EditInlineNew keywords.

Something like this :

image

Then you can instantiate and customize subojects directly in the Array defaults :

image

1 Like

Wow, thank you!! That’s HUGE. I was fully expecting it to be impossible in Unreal, what a pleasant surprise. When I figured this out in Unity I was mindblown, this kind of thing is super helpful for creating more complex architectures like GAS alternatives.

Thanks a lot, cheers.