From c5cb354ece5bcf2a39eabd6133f61b85019bb294 Mon Sep 17 00:00:00 2001 From: YBYCS <87234506+YBYCS@users.noreply.github.com> Date: Fri, 24 May 2024 18:54:29 +0800 Subject: [PATCH] =?UTF-8?q?[unreal]=E5=A2=9E=E5=8A=A0=E5=AF=B9metadata?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9=E6=A3=80=E6=9F=A5=E6=9D=A5=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=88=A0=E9=99=A4=E5=85=83=E6=95=B0=E6=8D=AE=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E8=A2=AB=E6=A3=80=E6=B5=8B=E4=B8=BA=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E9=87=8D=E6=96=B0=E7=BC=96=E8=AF=91=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#1733)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Private/PEBlueprintMetaData.cpp | 59 +++++++++++++++---- .../PuertsEditor/Public/PEBlueprintMetaData.h | 2 +- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/unreal/Puerts/Source/PuertsEditor/Private/PEBlueprintMetaData.cpp b/unreal/Puerts/Source/PuertsEditor/Private/PEBlueprintMetaData.cpp index aab1d9ae2f..cf6ef9c6be 100644 --- a/unreal/Puerts/Source/PuertsEditor/Private/PEBlueprintMetaData.cpp +++ b/unreal/Puerts/Source/PuertsEditor/Private/PEBlueprintMetaData.cpp @@ -106,8 +106,8 @@ bool UPEClassMetaData::Apply(UClass* InClass, UBlueprint* InBlueprint) MergeClassCategories(InClass); const bool bFlagsChanged = MergeAndValidateClassFlags(InClass); const bool bMetaDataChanged = SetClassMetaData(InClass); - SyncClassToBlueprint(InClass, InBlueprint); - return bFlagsChanged || bMetaDataChanged; + const bool bBlueprintMetaDataChange = SyncClassToBlueprint(InClass, InBlueprint); + return bFlagsChanged || bMetaDataChanged || bBlueprintMetaDataChange; } void UPEClassMetaData::MergeClassCategories(UClass* InParentClass) @@ -313,21 +313,56 @@ TArray UPEClassMetaData::GetClassMetaDataValues( return Result; } -void UPEClassMetaData::SyncClassToBlueprint(UClass* InClass, UBlueprint* InBlueprint) +bool UPEClassMetaData::SyncClassToBlueprint(UClass* InClass, UBlueprint* InBlueprint) { if (!IsValid(InClass) || !IsValid(InBlueprint)) { - return; + return false; + } + + bool onChange = false; + + if (InBlueprint->bDeprecate != (bool) (InClass->ClassFlags & CLASS_Deprecated)) + { + InBlueprint->bDeprecate = (bool) (InClass->ClassFlags & CLASS_Deprecated); + onChange = true; + } + if (InBlueprint->bGenerateAbstractClass != (bool) (InClass->ClassFlags & CLASS_Abstract)) + { + InBlueprint->bGenerateAbstractClass = (bool) (InClass->ClassFlags & CLASS_Abstract); + onChange = true; + } + FString newDescription = InClass->HasMetaData(TEXT("Tooltip")) ? InClass->GetMetaData(TEXT("Tooltip")) : FString{}; + if (InBlueprint->BlueprintDescription != newDescription) + { + InBlueprint->BlueprintDescription = newDescription; + onChange = true; + } + FString newDisplayName = InClass->HasMetaData(TEXT("DisplayName")) ? InClass->GetMetaData(TEXT("DisplayName")) : FString{}; + if (InBlueprint->BlueprintDisplayName != newDisplayName) + { + InBlueprint->BlueprintDisplayName = newDisplayName; + onChange = true; + } + EBlueprintType newType = (InClass->ClassFlags & CLASS_Const) ? BPTYPE_Const : BPTYPE_Normal; + if (InBlueprint->BlueprintType != newType) + { + InBlueprint->BlueprintType = newType; + onChange = true; + } + FString newCategory = InClass->HasMetaData(TEXT("Category")) ? InClass->GetMetaData(TEXT("Category")) : FString{}; + if (InBlueprint->BlueprintCategory != newCategory) + { + InBlueprint->BlueprintCategory = newCategory; + onChange = true; + } + if (InBlueprint->HideCategories != HideCategories) + { + InBlueprint->HideCategories = HideCategories; + onChange = true; } - InBlueprint->bDeprecate = (bool) (InClass->ClassFlags & CLASS_Deprecated); - InBlueprint->bGenerateAbstractClass = (bool) (InClass->ClassFlags & CLASS_Abstract); - InBlueprint->BlueprintDescription = InClass->HasMetaData(TEXT("Tooltip")) ? InClass->GetMetaData(TEXT("Tooltip")) : FString{}; - InBlueprint->BlueprintDisplayName = - InClass->HasMetaData(TEXT("DisplayName")) ? InClass->GetMetaData(TEXT("DisplayName")) : FString{}; - InBlueprint->BlueprintType = (InClass->ClassFlags & CLASS_Const) ? BPTYPE_Const : BPTYPE_Normal; - InBlueprint->BlueprintCategory = InClass->HasMetaData(TEXT("Category")) ? InClass->GetMetaData(TEXT("Category")) : FString{}; - InBlueprint->HideCategories = HideCategories; + return onChange; } void UPEClassMetaData::SetAndValidateWithinClass(UClass* InClass) diff --git a/unreal/Puerts/Source/PuertsEditor/Public/PEBlueprintMetaData.h b/unreal/Puerts/Source/PuertsEditor/Public/PEBlueprintMetaData.h index 1107b1b3bf..1881918658 100644 --- a/unreal/Puerts/Source/PuertsEditor/Public/PEBlueprintMetaData.h +++ b/unreal/Puerts/Source/PuertsEditor/Public/PEBlueprintMetaData.h @@ -461,7 +461,7 @@ class PUERTSEDITOR_API UPEClassMetaData : public UObject * @param InClass * @param InBlueprint */ - void SyncClassToBlueprint(UClass* InClass, UBlueprint* InBlueprint); + bool SyncClassToBlueprint(UClass* InClass, UBlueprint* InBlueprint); private: /**