Copy/Paste of components in bp scs now correctly maintain relative hierarchy

Duplicate of components in bp scs and iwce now correctly maintain relative hierarchy
Copy/Paste and Duplicate of components in bp scs and iwce now maintain the name of the source component where possible and a modified version of the name when already taken instead of using the component class as name
#jira UE-28153
#jira UE-47926
#jira UE-45180
#jira UE-50825
#rb Phillip.Kavan

[CL 4653522 by Marc Audy in Dev-Framework branch]
This commit is contained in:
Marc Audy
2018-12-12 12:43:01 -05:00
parent 6883d64fb7
commit b623e4364c
3 changed files with 99 additions and 38 deletions
@@ -1253,7 +1253,6 @@ USCS_Node* USimpleConstructionScript::CreateNode(UClass* NewComponentClass, FNam
check(NewComponentClass->IsChildOf(UActorComponent::StaticClass()));
ensure(Cast<UBlueprintGeneratedClass>(Blueprint->GeneratedClass));
// note that naming logic is duplicated in CreateNodeAndRenameComponent:
NewComponentVariableName = GenerateNewComponentName(NewComponentClass, NewComponentVariableName);
// At this point we should have a unique, explicit name to use for the template object.
@@ -1277,8 +1276,16 @@ USCS_Node* USimpleConstructionScript::CreateNodeAndRenameComponent(UActorCompone
{
check(NewComponentTemplate);
// note that naming logic is duplicated in CreateNode:
FName NewComponentVariableName = GenerateNewComponentName(NewComponentTemplate->GetClass());
// When copying and pasting we'd prefer to keep the component name
// However, the incoming template will have the template name suffix on it so
// acquire the desired name by stripping the suffix
FName DesiredName;
FString TemplateName = NewComponentTemplate->GetName();
if (TemplateName.EndsWith(ComponentTemplateNameSuffix))
{
DesiredName = *TemplateName.LeftChop(ComponentTemplateNameSuffix.Len());
}
FName NewComponentVariableName = GenerateNewComponentName(NewComponentTemplate->GetClass(), DesiredName);
// At this point we should have a unique, explicit name to use for the template object.
check(NewComponentVariableName != NAME_None);