Description

I did some research. The problem is caused in CoreNative.cpp.

In Function GetInstancedSubobject (Line 126)

We should check if instance is runtime instance first. If it is runtime instance, just use current value. Otherwise use the parent value. So I did some code change in Function GetInstancedSubobject like below, 

if ( bShouldInstance ) 
{ 
     // check bIsRuntime first
     bool bIsRuntimeInstance = CurrentValue != SourceSubobject && CurrentValue->GetOuter() == CurrentObject; 
     if (bDoNotCreateNewInstance || bIsRuntimeInstance) 
     { 
           InstancedSubobject = CurrentValue; 
     } 
     else {
         // do anything else 
         ...
     }
}
Steps to Reproduce
  1. Create three class in C++

 

UCLASS(EditInlineNew, DefaultToInstanced, Abstract, BlueprintType, Blueprintable)
class INSTANCETESTPROJECT_API USubObject : public UObject
{
      GENERATED_BODY()
public: 
      UPROPERTY(EditAnywhere) 
      FString String;
};

UCLASS(BlueprintType, Blueprintable, meta = (BlueprintSpawnableComponent))
class INSTANCETESTPROJECT_API UExampleComponent : public UActorComponent
{
      GENERATED_BODY()
public:
      UPROPERTY(EditAnywhere, Instanced)               
      class USubObject* SubObject = nullptr;
};

UCLASS(BlueprintType, Blueprintable)
class INSTANCETESTPROJECT_API ATestBPChildGameModeBase : public AGameModeBase
{
      GENERATED_BODY()  
      ATestBPChildGameModeBase()
      { 
            ExampleComp = CreateDefaultSubobject<UExampleComponent>(TEXT("ExampleComp")); 
      }
public: 
      UPROPERTY(EditAnywhere) 
      class UExampleComponent* ExampleComp;
};

 

2. Create New Blueprint in Editor from native class ATestBPChildGameModeBase, named as ParentGM.

 

3. Set SubObject in ParentGM as "parent"

 

4. Create New Blueprint in Editor from ParentGM, named as ChildGM

 

5. Set SubObject in ChildGM as "child"

 

6. Save all and close Editor

 

7. Reopen Editor, the SubObject in ChildGM is "parent"

 

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-102315 in the post.

0
Login to Vote

Won't Fix
ComponentUE - Gameplay - Components
Affects Versions4.25.3
CreatedNov 2, 2020
ResolvedJul 19, 2022
UpdatedJul 19, 2022
View Jira Issue