This is a regression that was introduced with changes made to address issues with native vs. non-native component registration at Blueprint construction time ([Link Removed]).
Prior to those changes, unregistered scene components were "accidentally" being registered during Blueprint Actor instance reconstruction as part of a "catch-all" loop. That loop has been removed as part of the refactor, so that fallback is no longer in place.
The suggested workaround is to explicitly register nested scene component subobjects inside of an OnRegister() method override, implemented on the owning component's native C++ class.
1. Launch the editor and create a new (blank) C++ project.
2. Add a new C++ class based on SceneComponent (call it MySceneComp).
3. Add a new C++ class based on SceneComponent (call it MyNestedSceneComp).
4. Modify MySceneComp.h to include the following in the class decl:
public: UPROPERTY() class UMyNestedSceneComp* NestedSceneComp; virtual void OnRegister() override;
5. Modify MySceneComp.cpp to include the following:
#include "MyNestedSceneComp.h" DEFINE_LOG_CATEGORY_STATIC(LogMySceneComp, Log, All); // Add this into the constructor's implementation: NestedSceneComp = CreateDefaultSubobject<UMyNestedSceneComp>(TEXT("NestedSceneComp")); // Add this method implementation: void UMySceneComp::OnRegister() { Super::OnRegister(); UE_LOG(LogMySceneComp, Log, TEXT("MySceneComp - OnRegister")); }
6. Modify MyNestedSceneComp.h to include the following in the class decl:
virtual void OnRegister() override;
7. Modify MyNestedSceneComp.cpp to include the following:
DEFINE_LOG_CATEGORY_STATIC(LogMyNestedSceneComp, Log, All); // Add this method implementation: void UMyNestedSceneComp::OnRegister() { Super::OnRegister(); UE_LOG(LogMyNestedSceneComp, Log, TEXT("MyNestedSceneComp - OnRegister")); }
8. Recompile the project in Visual Studio and wait for the UE4 editor to hot-reload the updated class.
9. Back in the UE4 editor, create a new Blueprint class based on Actor.
10. Drag an instance of the new Blueprint class into the scene and select it.
11. In the Details view, click the "Add Component" drop-down and choose "MyNestedSceneComp."
12. Open the output log window. The message "MyNestedSceneComp - OnRegister" should be visible.
13. Back in the Details view, click the "Add Component" drop-down again and choose "MySceneComp"
14. The message "MySceneComp - OnRegister" should be visible. However, the message "MyNestedSceneComp - OnRegister" is not visible, which indicates that the nested MyNestedSceneComp subobject did not get registered along with it.
Expected result: The nested subobject (MyNestedSceneComp in this case) should have been registered along with the outer component (MySceneComp in this case). Both log messages should be printed out as a result.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-38690 in the post.
0 |
Component | UE - Gameplay - Components |
---|---|
Affects Versions | 4.14 |
Target Fix | 4.14.1 |
Fix Commit | 3208013 |
---|
Created | Nov 16, 2016 |
---|---|
Resolved | Nov 22, 2016 |
Updated | Feb 5, 2017 |