[unreal]Fix:增加对Class Metadata的修改检查来修复删除元数据不会被检测为更改而不重新编译的问题 #1733
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题:将@uclass.umeta(uclass.DisplayName="展示名字")中的uclass.DisplayName="展示名字"整个删除,不会触发重新编译蓝图(修改内容和增加没问题)
原因:bool FPEMetaDataUtils::AddMetaData(UField* InField, TMap<FName, FString>& InMetaData) 只对收集到的metadata只做了增加和修改的检查没有处理删除的检查,导致删除metadata不会被识别为发生更改,进而导致没有重新编译
解决方法:按直觉来说应该是在这个函数增加一个检查删除的逻辑,但是该函数使用的蓝图生成类中拥有的元数据可能包含了父类和其他一些定义的元数据,如HideCategories、BlueprintType,如果还是同样的思路来比较蓝图生成类拥有的元数据和收集到的元数据,就需要移除掉这些外来的元数据(即不是在ts文件中定义的元数据),但是这样的话和引擎的耦合比较大,即需要完全查明所有不在ts文件中定义的但是在蓝图生成类中有的(还可能因为版本不同而不同),故采取了另一种方法:
考虑到编译蓝图完全依赖于蓝图类,我们可以只检查puerts本身实现的能够正确配置的元数据是否被删除了即可,即SyncClassToBlueprint这个函数中同步的那些元数据(其他不在该函数赋值的元数据,本身即使编译了也不会正确赋值到蓝图中诸如一些弃用的或者是在编译过程中会被覆盖的元数据)