Skip to content

Commit

Permalink
[unreal]增加对metadata的修改检查来修复删除元数据不会被检测为更改而不重新编译的问题 (Tencent#1733)
Browse files Browse the repository at this point in the history
  • Loading branch information
YBYCS authored and mingxxming committed May 28, 2024
1 parent aeb1a5d commit c5cb354
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
59 changes: 47 additions & 12 deletions unreal/Puerts/Source/PuertsEditor/Private/PEBlueprintMetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -313,21 +313,56 @@ TArray<FString> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
/**
Expand Down

0 comments on commit c5cb354

Please sign in to comment.