#Dyanmic UObject subclass properties not showing in details view

1 messages · Page 1 of 1 (latest)

viral bay
#

Hey,

I have been banging my head trying to get this to work.
I'm trying to have a dynamically spawned UObject of a type specified by a TSubObjectOf have it properties show in a details panel.
But all that will show are the Properties of the base class, not the sub class given given from the TSubObjectOf

Small example below.

The 2 UObject I want to display

UCLASS(Blueprintable, editinlinenew)
class  UTestBaseClass : public UObject
{
    GENERATED_BODY()

public:
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Test")
    FVector BaseClassTest;
};
UCLASS(Blueprintable, editinlinenew)
class  USubClassTest : public UTestBaseClass
{
    GENERATED_BODY()

public:
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Test")
    FVector SubClassTest;
};

The class that holds them

UCLASS(Transient)
class UTestToolProperties : public UInteractiveToolPropertySet
{
    GENERATED_BODY()
public:
    UTestToolProperties();

    UPROPERTY(EditAnywhere, Category = Options)
    TSubclassOf<UTestBaseClass> ObjType;

    UPROPERTY(Instanced, EditAnywhere, Category = Options)
    TObjectPtr<UTestBaseClass> TestObj;

    virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override
    {
        Super::PostEditChangeProperty(PropertyChangedEvent);

        if (PropertyChangedEvent.Property->GetName() == "ObjType" && ObjType != nullptr)
        {
            TestObj= NewObject<UBrushGen>(ObjType);
        }
    }
};

The problem is that I can only ever get it to show the properties of the UTestBaseClass, I was hoping I could have it use the reflection data of the class given by TSubclassOf<UTestBaseClass> ObjType, but no luck.
I have also tried to use detail customization to have it show them that way by adding AddExternalObjectProperty, but no luck.

I can loop over all the properties, I just can't see a way to have them display in details view.

sullen warren
#

Does the above work if you instead create the object in the editor, rather than through PostEditChangeProperty code?

#

As doing it that way has worked for me, you pick the subclass from the list in the editor and it shows the appropriate properties in the details panel

#

Not actually sure why you need the TSubclassOf property, you can just have an instanced pointer to the base class

#

Or maybe I've misunderstood something about the question?

viral bay
#

I am now both happy and sad lol
That does indeed work, before they weren't showing in the editor drop down for just the but does now and seem to do everything I was looking for, I prop missed a meta specifier the first time and then just blindly dove into over engeringing >,>

#

Thanks for saving the rest of my sanity <3

sullen warren
#

Yes, we're all prone to over-engineering 🙂

lean cypress
#

you're not making these edits (header/UPROP edits) with Live Coding/hot reload are you?

sullen warren
#

Sounds like you have it working, but just in case it's useful - I've used these properties for the base class:
UCLASS(Blueprintable, DefaultToInstanced, EditInlineNew, CollapseCategories, HideCategories = Object, Abstract)

And on the property that holds them:
Instanced, EditAnywhere, Export

viral bay