[{"data":1,"prerenderedAt":259},["ShallowReactive",2],{"\u002F2017-06-05-ue4-transition-log":3},{"id":4,"title":5,"body":6,"date":236,"description":12,"extension":237,"meta":238,"navigation":241,"path":253,"seo":254,"stem":255,"tags":256,"__hash__":258},"blogs\u002F_legacy\u002F2017\u002F2017-06-05-ue4-transition-log.md","UE4项目迁移笔记",{"type":7,"value":8,"toc":229},"minimark",[9,13,16,19,24,27,38,41,44,50,53,59,62,65,69,72,75,78,84,87,93,96,99,102,108,111,117,120,126,129,135,138,141,145,148,151,157,160,163,174,177,184,187,190,196,199,202,205,211,214,220,223,226],[10,11,12],"p",{},"UE4本身的版本升级比较频繁，这就会导致有时候手里的或是网上下载的项目需要进行版本迁移。",[10,14,15],{},"通常情况下，如果是在小的版本之间迁移，尤其是跟着官方的步伐进行更新的话，都不会遇到什么大问题。但是如果在现在版本是4.16的情况下，要对4.7版本的项目进行迁移的话，就会有很多问题。",[10,17,18],{},"这次遇到的问题就是从网上下载的示例项目版本太旧，需要进行大的版本迁移。原本以为不会有什么太多麻烦，不想却还是花了很多时间，因此在这里记录一下。",[20,21,23],"h2",{"id":22},"build-rules","Build Rules",[10,25,26],{},"对项目进行编译，非常幸运，首先只遇到了几个Warning：",[28,29,34],"pre",{"className":30,"code":32,"language":33},[31],"language-text","1>E:\\Ues\\GAS\\Source\\GAS\\GAS.Build.cs : warning : Module constructors should take a ReadOnlyTargetRules argument (rather than a TargetInfo argument) and pass it to the base class constructor from 4.15 onwards. Please update the method signature.\n1>E:\\Ues\\GAS\\Source\\GAS.Target.cs : warning : SetupBinaries() is deprecated in the 4.16 release. From the constructor in your .target.cs file, use ExtraModuleNames.Add(\"Foo\") to add modules to your target, or set LaunchModuleName = \"Foo\" to override the name of the launch module for program targets.\n1>E:\\Ues\\GAS\\Source\\GASEditor.Target.cs : warning : SetupBinaries() is deprecated in the 4.16 release. From the constructor in your .target.cs file, use ExtraModuleNames.Add(\"Foo\") to add modules to your target, or set LaunchModuleName = \"Foo\" to override the name of the launch module for program targets.\n","text",[35,36,32],"code",{"__ignoreMap":37},"",[10,39,40],{},"UE4最近的两次版本升级中对BuildRule进行了变更，所以在这里只要按照提示进行修改就可以了。只是官方的提示多少有些简略，实际操作是类似这样的。",[10,42,43],{},"*.build.cs",[28,45,48],{"className":46,"code":47,"language":33},[31],"public class GAS : ModuleRules\n{\n-    public GAS(TargetInfo Target)\n+    public GAS(ReadOnlyTargetRules Target) : base(Target)\n",[35,49,47],{"__ignoreMap":37},[10,51,52],{},"*.Target.cs",[28,54,57],{"className":55,"code":56,"language":33},[31],"public class GASTarget : TargetRules\n{\n-    public GASTarget(TargetInfo Target)\n+    public    GASTarget(TargetInfo Target) : base(Target)\n     {\n        Type = TargetType.Game;\n-    }\n-\n-    \u002F\u002F\n-    \u002F\u002F TargetRules interface.\n-    \u002F\u002F\n-\n-    public override void SetupBinaries(\n-          TargetInfo Target,\n-          ref List\u003CUEBuildBinaryConfiguration> OutBuildBinaryConfigurations,\n-          ref List\u003Cstring> OutExtraModuleNames\n-          )\n-    {\n-          OutExtraModuleNames.Add(\"GAS\");\n+          ExtraModuleNames.Add(\"GAS\");\n",[35,58,56],{"__ignoreMap":37},[10,60,61],{},"要留意的是，TargetRule有两个配置文件，一个是给Game的一个是给Editor的。",[10,63,64],{},"改了之后就没有提示了。",[20,66,68],{"id":67},"iwyu","IWYU",[10,70,71],{},"既然升级了BuildRules，那就自然会要使用官方在4.15新推出的号称减少50%编译时间的IWYU了。",[10,73,74],{},"这个技术似乎是优化了预编译头的处理机制，但是使用起来需要自己进行定义和设置，并不是升到4.15以上就能全面享用的优势呢。",[10,76,77],{},"首先要做的是到*.build.cs中，在ModuleRules中添加一行，类似这样：",[28,79,82],{"className":80,"code":81,"language":33},[31],"\u002F\u002F Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.\n\nusing UnrealBuildTool;\n\npublic class GAS : ModuleRules\n{\n    public GAS(ReadOnlyTargetRules Target) : base(Target)\n    {\n        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;\n\n       \u002F\u002F Some other code def\n\n    }\n}\n",[35,83,81],{"__ignoreMap":37},[10,85,86],{},"添加这行修改预编译头机制后，编译必然会遇到很多类似这样的错误：",[28,88,91],{"className":89,"code":90,"language":33},[31],"1>E:\\Ues\\GAS\\Source\\GAS\\DamageExecution.cpp(1): error : Expected DamageExecution.h to be first header included.\n1>E:\\Ues\\GAS\\Source\\GAS\\GASAttributeSet.cpp(1): error : Expected GASAttributeSet.h to be first header included.\n1>E:\\Ues\\GAS\\Source\\GAS\\GASBlueprintLibrary.cpp(1): error : Expected GASBlueprintLibrary.h to be first header included.\n",[35,92,90],{"__ignoreMap":37},[10,94,95],{},"新的PCH机制要求cpp文件必须首先包含自己的头文件，按照提示一个一个对源文件进行修改就好了。",[10,97,98],{},"此外还会遇到很多类型未定义以及由此引发的其他错误，如果有VA的话，可以对应着进行添加包含。要注意的是，连FString这样的基础类型都会有这个问题，所以还是颇为防不胜防。",[10,100,101],{},"官方推荐的是在项目的头文件中包含",[28,103,106],{"className":104,"code":105,"language":33},[31],"#include “CoreMinimal.h”\n",[35,107,105],{"__ignoreMap":37},[10,109,110],{},"当然必要的时候可能需要包含",[28,112,115],{"className":113,"code":114,"language":33},[31],"#include “EngineMinimal.h”\n",[35,116,114],{"__ignoreMap":37},[10,118,119],{},"如果项目中使用到了UEngine的话，可以选择包含",[28,121,124],{"className":122,"code":123,"language":33},[31],"#include “Engine\u002FEngine.h”\n",[35,125,123],{"__ignoreMap":37},[10,127,128],{},"但是，实际上，如果对引擎比较深的地方的类进行了继承的话，最后还是得包含",[28,130,133],{"className":131,"code":132,"language":33},[31],"#include \"Engine.h\"\n",[35,134,132],{"__ignoreMap":37},[10,136,137],{},"要不然可能会被报错到引擎的源代码里面去。",[10,139,140],{},"进行包含调整之后，基本就编译通过了。",[20,142,144],{"id":143},"load-module-error","Load Module Error",[10,146,147],{},"原本以为编译通过了就万事大吉了，没想到在运行项目时却遇到了无法打开的问题……",[10,149,150],{},"使用VS进行调试运行，会看到这样的错误：",[28,152,155],{"className":153,"code":154,"language":33},[31],"[2017.06.04-02.48.31:217][ 0]LogModuleManager:Warning: ModuleManager: Unable to load module 'E:\u002FUes\u002FGAS\u002FBinaries\u002FWin64\u002FUE4Editor-GAS-Win64-DebugGame.dll' because the file couldn't be loaded by the OS.\n",[35,156,154],{"__ignoreMap":37},[10,158,159],{},"首先当然是怀疑dll文件不存在，但是实际上dll文件是存在的，那么问题出在哪里了呢？",[10,161,162],{},"求助万能的Google，终于找到了调试的方法。",[10,164,165,166,173],{},"这个时候需要使用微软官方的Debugging Tools for Windows，按照微软官方描述该工具被包含在WDK和Windows SDK中，因此直接",[167,168,172],"a",{"href":169,"rel":170},"http:\u002F\u002Fgo.microsoft.com\u002Ffwlink\u002Fp?LinkID=271979",[171],"nofollow","install the Windows SDK","，在安装的时候只勾选Debugging Tools for Windows就好了。",[10,175,176],{},"安装完成之后打开其中的一个名为Global Flags的工具，进行配置：",[10,178,179],{},[180,181],"img",{"alt":182,"src":183},"clip_image001","\u002Fwp-content\u002Fuploads\u002F2017\u002F06\u002Fclip_image001_thumb-1.png",[10,185,186],{},"只要选择Show Loader Snaps就好了，保存选项，重启电脑。",[10,188,189],{},"然后重新在VS中调试运行项目，在上一次遇到错误的地方就可以看到：",[28,191,194],{"className":192,"code":193,"language":33},[31],"2264:05b0 @ 00793859 - LdrpSearchPath - ENTER: DLL name: UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793859 - LdrpComputeLazyDllPath - INFO: DLL search path computed: D:\\Code\\UE_4.16\\Engine\\Binaries\\Win64;E:\u002FUes\u002FGAS\u002FBinaries\u002FWin64;C:\\Windows\\SYSTEM32;C:\\Windows\\system;C:\\Windows;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;D:\\Tools\\Git\\cmd;C:\\Program Files (x86)\\Windows Live\\Shared;D:\\Tools\\SVN\\bin;D:\\Code\\Python\\Scripts\\;D:\\Code\\Python\\;C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\WindowsApps;;D:\\Tools\\Microsoft VS Code\\bin\n2264:05b0 @ 00793859 - LdrpResolveDllName - ENTER: DLL name: D:\\Code\\UE_4.16\\Engine\\Binaries\\Win64\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793859 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793859 - LdrpResolveDllName - ENTER: DLL name: E:\u002FUes\u002FGAS\u002FBinaries\u002FWin64\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793859 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793859 - LdrpResolveDllName - ENTER: DLL name: C:\\Windows\\SYSTEM32\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793859 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793859 - LdrpResolveDllName - ENTER: DLL name: C:\\Windows\\system\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793859 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793859 - LdrpResolveDllName - ENTER: DLL name: C:\\Windows\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: C:\\Windows\\system32\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: C:\\Windows\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: C:\\Windows\\System32\\Wbem\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: D:\\Tools\\Git\\cmd\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: C:\\Program Files (x86)\\Windows Live\\Shared\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: D:\\Tools\\SVN\\bin\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: D:\\Code\\Python\\Scripts\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: D:\\Code\\Python\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\WindowsApps\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpResolveDllName - ENTER: DLL name: D:\\Tools\\Microsoft VS Code\\bin\\UE4Editor-GameplayAbilities.dll\n2264:05b0 @ 00793875 - LdrpResolveDllName - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpSearchPath - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrpProcessWork - ERROR: Unable to load DLL: \"UE4Editor-GameplayAbilities.dll\", Parent Module: \"E:\\Ues\\GAS\\Binaries\\Win64\\UE4Editor-GAS.dll\", Status: 0xc0000135\n“UE4Editor.exe”(Win32): 已卸载“E:\\Ues\\GAS\\Binaries\\Win64\\UE4Editor-GAS.dll”\n2264:05b0 @ 00793875 - LdrpLoadDllInternal - RETURN: Status: 0xc0000135\n2264:05b0 @ 00793875 - LdrLoadDll - RETURN: Status: 0xc0000135\n[2017.06.04-03.19.55:171][ 0]LogModuleManager:Warning: ModuleManager: Unable to load module 'E:\u002FUes\u002FGAS\u002FBinaries\u002FWin64\u002FUE4Editor-GAS.dll' because the file couldn't be loaded by the OS.\n",[35,195,193],{"__ignoreMap":37},[10,197,198],{},"错误原因原来是UE4Editor-GameplayAbilities.dll找不到了，但是这个是引擎提供的内容，为什么会找不到呢？",[10,200,201],{},"费了一阵脑筋之后才想起来，似乎从某个版本开始，GamePlayAbility由引擎的Module转变为了Plugin，目的是为了避免不需要这个系统的项目包含不必要的内容。",[10,203,204],{},"因此直接对项目文件进行编辑，将下面的内容：",[28,206,209],{"className":207,"code":208,"language":33},[31],"{\n    \"FileVersion\": 3,\n    \"EngineAssociation\": \"\",\n    \"Category\": \"\",\n    \"Description\": \"\",\n    \"Modules\": [\n    {\n        \"Name\": \"GAS\",\n        \"Type\": \"Runtime\",\n        \"LoadingPhase\": \"Default\",\n        \"AdditionalDependencies\": [\n            \"GameplayAbilities\",\n            \"Engine\"\n        ]\n    }\n    ]\n\n}\n",[35,210,208],{"__ignoreMap":37},[10,212,213],{},"改为：",[28,215,218],{"className":216,"code":217,"language":33},[31],"{\n    \"FileVersion\": 3,\n    \"EngineAssociation\": \"4.16\",\n    \"Category\": \"\",\n    \"Description\": \"\",\n    \"Modules\": [\n        {\n            \"Name\": \"GAS\",\n            \"Type\": \"Runtime\",\n            \"LoadingPhase\": \"Default\",\n            \"AdditionalDependencies\": [\n                \"Engine\"\n            ]\n        }\n    ],\n    \"Plugins\": [\n        {\n            \"Name\": \"GameplayAbilities\",\n            \"Enabled\": true\n        }\n    ]\n}\n",[35,219,217],{"__ignoreMap":37},[10,221,222],{},"重新编译，这样一来终于能够运行了。",[10,224,225],{},"不过Module的加载错误因项目而异，遇到这种错误还是必须使用GFlag进行调试才行。",[10,227,228],{},"最后，不要忘记在GFlag中把调试选项关掉，要不然调试运行速度会很感人的。",{"title":37,"searchDepth":230,"depth":231,"links":232},2,3,[233,234,235],{"id":22,"depth":230,"text":23},{"id":67,"depth":230,"text":68},{"id":143,"depth":230,"text":144},"2017-06-05","md",{"layout":239,"status":240,"published":241,"author":242,"author_login":244,"author_email":245,"wordpress_id":246,"wordpress_url":247,"date_gmt":248,"excerpt":249},"post","publish",true,{"display_name":243,"login":244,"email":245,"url":37},"风铃","flinkor","flinkor@foxmail.com",1771,"\u002F\u002F?p=1771","2017-06-05 13:38:21 +0000",{"type":7,"value":250},[251],[10,252,12],{},"\u002F2017-06-05-ue4-transition-log",{"title":5,"description":12},"_legacy\u002F2017\u002F2017-06-05-ue4-transition-log",[257],"UE4","0iGe3VdYh10THWts3bUSuhKTRSuDSFHgXdb-IH4CPnk",1788763179982]