Hi everyone,
I am having a problem with extending C++ classes to blueprints, and with TSubClassOf.
I am trying to create an attachment system. I have a base class in C++, UAttachmentBase, inheriting from UObject. I have then created another C++ class inheriting from this, called USightAttachment, with Blueprintable and BlueprintType in the UCLASS macro.
I then created a blueprint inheriting from the USightAttachment class, called DefaultSightAttachment.
I want to be able to select a subclass of USightAttachment from a USTRUCT(BlueprintType) in another class, so I have the following struct definition:
USTRUCT(BlueprintType)
struct FWeaponAttachmentsStruct
{
GENERATED_BODY()
public:
//Sight attachment
UPROPERTY(EditDefaultsOnly, Category = "Weapon Attachments")
TSubclassOf<USightAttachment> SightAttachment;
};
and I make the struct accessible (along with some other structs) in another blueprint.
However, when assigning the variable in the blueprint, instead of restricting the selection of SightAttachment to just USightAttachment class, it allows all classes.
I want to only be able to select USightAttachment classes from this, similar to the system whereby a variable defined as UStaticMesh* and exposed to the blueprint editor will only allow selection of static meshes.
Strangely the TSubClass works with a separate class, AFPSProjectile
UPROPERTY(EditDefaultsOnly, Category = "Projectile")
TSubclassOf<class AFPSProjectile> ProjectileClass;
But this is an actor class, and I am not using an actor class for my attachments. I also tried with the class USightAttachment in the <> but this did not work either.
Any help would be appreciated.