Download

Creating Easily Configurable Custom Classes

Hello,

I’m somewhat new to Unreal and its intricacies so apologies if this is something that either cannot or should not be done.

Assume we have a C++ class with a UPROPERTY(…) UStaticMeshComponent*, which is exposed to the editor. When we do so and view it in the editor, we get a drop down list of all the types of UStaticMeshComponent derived classes, and can choose one to use instead, or stick with the basic component. We can however then expand this, and configure the properties of this component, such as the static mesh to use, and its material override.

My question is, how I would apply a similar approach to developing custom classes, wherein both the class and properties are changeable in the editor? I understand I could use TSubclassOf<Custom> to get the drop down list, and choose which type of object to create, which is okay, or to achieve the property setting feature I could make it a straightforward Custom* and set its properties in the editor.

The problem is that neither are sufficient in my case. Here, I have a UCharacterWeapon component that creates ABullet objects, perhaps many in any given shot. The idea was to use


UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Bullets")
TArray<ABullet*> bulletsInEachShot;

in the weapon component, which I hoped would be exposed as you would expect a TArray<UStaticMeshComponent*> to be exposed. This would be useful as the weapon could create different classes of bullets in every shot, and as such give the team a lot of flexibility in designing new weapons.

This could very well be a symptom of bullets being Actors, meaning they cannot be configured in this way, or it could just be that UStaticMeshComponent has very good built-in support, or perhaps an issue with exposing a TArray.

Does anyone have suggestions on how to achieve this, or should I look into different methods?

Thanks in advance,
Jake

Take a look at Data Tables.