Hi,
I’ve run into an issue where UWorldPartition::ResolveSubobject() fails to resolve a subobject path like !StaticMeshActor_UAID_CC96E530724C2F6302_1896940416.StaticMeshComponent0. Looking at the code I believe that the call to GetActorDescInstanceByPath() is using SubObjectName where it should be using SubObjectContext because with paths like this not SubObjectName won’t match any actor descriptor since it is the name of the component. This is what the code currently looks like.
bool UWorldPartition::ResolveSubobject(const TCHAR* SubObjectPath, UObject*& OutObject, bool bLoadIfExists)
{
// ...
#if WITH_EDITOR
else
{
// Support for subobjects such as Actor.Component
FString SubObjectName;
FString SubObjectContext;
if (!FString(SubObjectPath).Split(TEXT("."), &SubObjectContext, &SubObjectName))
{
SubObjectName = SubObjectPath;
}
if (const FWorldPartitionActorDescInstance* ActorDescInstance = GetActorDescInstanceByPath(SubObjectName))
{
if (bLoadIfExists)
{
LoadedSubobjects.Emplace(this, ActorDescInstance->GetGuid());
}
OutObject = StaticFindObject(UObject::StaticClass(), GetWorld()->PersistentLevel, SubObjectPath);
return true;
}
}
#endif
}
return false;
}
This is what I believe it should look like.
bool UWorldPartition::ResolveSubobject(const TCHAR* SubObjectPath, UObject*& OutObject, bool bLoadIfExists)
{
// ...
#if WITH_EDITOR
else
{
// Support for subobjects such as Actor.Component
FString SubObjectName;
FString SubObjectContext;
if (!FString(SubObjectPath).Split(TEXT("."), &SubObjectContext, &SubObjectName))
{
SubObjectContext = SubObjectPath;
}
if (const FWorldPartitionActorDescInstance* ActorDescInstance = GetActorDescInstanceByPath(SubObjectContext))
{
if (bLoadIfExists)
{
LoadedSubobjects.Emplace(this, ActorDescInstance->GetGuid());
}
OutObject = StaticFindObject(UObject::StaticClass(), GetWorld()->PersistentLevel, SubObjectPath);
return true;
}
}
#endif
}
return false;
}
For my use-case, ResolveSubObject() works the way I expect it to after these changes. Is this a bug or is there something I’m missing?
Best regards
Michael Andersson