Runtime-generated components stored in ObjectPtr with VisibleAnywhere are displayed in the details panel, but not for arrays.
Applying the following workaround, components can be visible even in arrays.
FProperty* FComponentEditorUtils::GetPropertyForEditableNativeComponent(const UActorComponent* NativeComponent) { // A native component can be edited if it is bound to a member variable and that variable is marked as visible in the editor // Note: We aren't concerned with whether the component is marked editable - the component itself is responsible for determining which of its properties are editable UObject* ComponentOuter = (NativeComponent ? NativeComponent->GetOuter() : nullptr); UClass* OwnerClass = (ComponentOuter ? ComponentOuter->GetClass() : nullptr); UObject* OwnerCDO = (OwnerClass ? OwnerClass->GetDefaultObject() : nullptr); ... // We have to check for array properties as well because they are not FObjectProperties and we want to be able to // edit the inside of it if (OwnerCDO != nullptr) { for (TFieldIterator<FArrayProperty> PropIt(OwnerClass, EFieldIteratorFlags::IncludeSuper); PropIt; ++PropIt) { FArrayProperty* TestProperty = *PropIt; // void* ArrayPropInstAddress = TestProperty->ContainerPtrToValuePtr<void>(OwnerCDO); void* ArrayPropInstAddress = TestProperty->ContainerPtrToValuePtr<void>(ComponentOuter); //workaround // Ensure that this property is valid FObjectProperty* ArrayEntryProp = CastField<FObjectProperty>(TestProperty->Inner); if ((ArrayEntryProp == nullptr) || !ArrayEntryProp->PropertyClass->IsChildOf<UActorComponent>() || ((TestProperty->PropertyFlags & CPF_Edit) == 0)) { continue; }
Result:
Runtime generated components are not visible in details pane.
[Link Removed]
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-158069 in the post.
1 |
Component | UE - Gameplay - Components |
---|---|
Affects Versions | 5.0 |
Target Fix | 5.3 |
Fix Commit | 25287196 |
---|---|
Main Commit | 25288926 |
Created | Jun 30, 2022 |
---|---|
Resolved | May 1, 2023 |
Updated | May 3, 2023 |