Hiding UObject* instanced property class-selector dropdown.

Is there any way to hide the class-selector drop down from UObject inline properties?

image

I would love to be able to hide the TestObjectProperty line entirely. I currently use structs and IPropertyTypeCustomization to hide the header (similar to ShowOnlyInnerProperties), and the only thing that’s putting me off using UObject, which would be more flexible for my needs, is that I haven’t figured out how to hide the header.

UPROPERTY(EditAnywhere, Instanced, NoClear, meta=(NoResetToDefault, ShowOnlyInnerProperties))
UTestObjectParam* TestObjectProperty = NewObject<UTestObjectParam>();

I’ve tried slapping on every uproperty specifier I could think might do the trick but no bueno.

I have also attempted to write a detail panel customization for UTestObjectParam but unlike IPropertyTypeCustomization it doesn’t appear clear how to override the property header.

I would love a way to replace struct params with polymorphic uobject params but displayed exactly the same a struct param with ShowOnlyInnerProperties would be.

As an experiment, I put UTestObjectParam* TestObjectProperty in a struct, and in the customisation, I put the following:

void FTestObjectStruct_DC::CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
{
	TSharedPtr<IPropertyHandle> UObjectParamHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FTestObjectStruct, NewTestObject));
	TSharedPtr<IPropertyHandle> VectorParamHandle = UObjectParamHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(UTestObjectParam, VectorParam));

	// This param displays correctly.
	if (VectorParamHandle.IsValid())
		IDetailPropertyRow& TestRow = StructBuilder.AddProperty(VectorParamHandle.ToSharedRef());
	

	// This displays an object path?
	uint32 NumChildren;
	UObjectParamHandle->GetNumChildren(NumChildren);

	LOG_ERROR("Number of children: " + FString::FromInt(NumChildren))

	for (uint32 Index = 0; Index < NumChildren; ++Index)
	{
		TSharedPtr<IPropertyHandle> ChildHandle = UObjectParamHandle->GetChildHandle(Index);
		if (!ChildHandle.IsValid())
			continue;

		IDetailPropertyRow& NewRow = StructBuilder.AddProperty(ChildHandle.ToSharedRef());
	}
}

And it displays like this:

So I can hide the UObject header by wrapping it in a struct and displaying the UObject inner properties only. BUT getting the child property for VectorParam directly works, but attempting to iterate through the child properties, the log tells me “Number of Children: 1” and it prints the path above.

I’ll keep digging to see if I can simply iterate over the child properties to show them. I don’t think manually displaying every property on these UObject params is going to work, it’s way too much.

I found a solution for anyone who might be looking for the same thing:

void FTestObjectStruct_DC::CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
{
	TSharedPtr<IPropertyHandle> UObjectParamHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FTestObjectStruct, NewTestObject));

	if (UObjectParamHandle.IsValid() && UObjectParamHandle->IsValidHandle())
	{
		UObject* UObjectValue = nullptr;
		UObjectParamHandle->GetValue(UObjectValue);

		if (UObjectValue)
		{
			UClass* ObjectClass = UObjectValue->GetClass();
			for (TFieldIterator<FProperty> PropIt(ObjectClass); PropIt; ++PropIt)
			{
				FProperty* Property = *PropIt;
				TSharedPtr<IPropertyHandle> ChildHandle = UObjectParamHandle->GetChildHandle(Property->GetFName());
				if (ChildHandle.IsValid())
				{
					StructBuilder.AddProperty(ChildHandle.ToSharedRef());
				}
			}
		}
	}
}
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.