Files
UnrealEngineUWP/Engine/Source/Editor/SubobjectDataInterface/Private/InheritedSubobjectData.cpp
ben hoffman c968dafbd0 [Subobject Editor] Allow deletion of subobjects that are the default scene root so that they get properly replaced with a "DefaultSceneRoot" in the subobject blueprint editor.
#jira UE-125204
#rb phillip.kavan
#rnx

#ROBOMERGE-AUTHOR: ben.hoffman
#ROBOMERGE-SOURCE: CL 17621477 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v871-17566257)
#ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0

[CL 17621478 by ben hoffman in ue5-release-engine-test branch]
2021-09-24 11:06:45 -04:00

59 lines
1.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "InheritedSubobjectData.h"
#include "Kismet2/ComponentEditorUtils.h"
FInheritedSubobjectData::FInheritedSubobjectData(UObject* ContextObject, const FSubobjectDataHandle& ParentHandle, const bool InbIsInheritedSCS)
: FSubobjectData(ContextObject, ParentHandle)
, bIsInheritedSCS(InbIsInheritedSCS)
{
}
bool FInheritedSubobjectData::IsNativeComponent() const
{
if (const UActorComponent* Template = GetComponentTemplate())
{
return Template->CreationMethod == EComponentCreationMethod::Native && GetSCSNode() == nullptr;
}
return false;
}
bool FInheritedSubobjectData::CanEdit() const
{
if(IsComponent())
{
if(IsInstancedInheritedComponent())
{
const UActorComponent* Template = GetComponentTemplate();
return (Template ? Template->IsEditableWhenInherited() : false);
}
else if (!IsNativeComponent())
{
USCS_Node* SCS_Node = GetSCSNode();
return (SCS_Node != nullptr);
}
else if (const UActorComponent* ComponentTemplate = GetComponentTemplate())
{
return FComponentEditorUtils::GetPropertyForEditableNativeComponent(ComponentTemplate) != nullptr;
}
}
return FSubobjectData::CanEdit();
}
bool FInheritedSubobjectData::CanDelete() const
{
if(IsInheritedComponent() || (IsDefaultSceneRoot() && SceneRootHasDefaultName()) || (GetSCSNode() != nullptr && IsInstancedInheritedComponent()) || IsChildActorSubtreeObject())
{
return false;
}
return true;
}
bool FInheritedSubobjectData::IsInheritedSCSNode() const
{
return bIsInheritedSCS;
}