UE4 编译、打包、运行 问题汇总

  • 编译时 error C4668: 没有将“_WIN32_WINNT_WIN10_TH2”定义为预处理器宏,用“0”替换“#if/#elif”

一般为Windows中的宏和UE4冲突所致,需要用如下头文件包裹冲突的头文件:

#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/PreWindowsApi.h"

#include "冲突的头文件"

#include "Windows/PostWindowsApi.h"
#include "Windows/HideWindowsPlatformTypes.h"
  • 编译时 FindPathToActorSynchronously() function not working!

ACharacter *PlayerPawn = UGameplayStatics::GetPlayerCharacter(this, 0);
UNavigationPath *NavPath = UNavigationSystemV1::FindPathToActorSynchronously(this, GetActorLocation(), PlayerPawn);

检查 Build.cs 文件 PublicDependencyModuleNames.AddRange(new string[] { "NavigationSystem" });看是否添加了此模块。

  • 打包时 ERROR: Couldn't find target rules file for target 'UE4Game' 

把项目对应的.uproject 里头的“EnterPrise”:true删掉就好了。

  • UWidgetComponent::GetUserWidgetObject() LNK error.

UUserWidget *MyWidget = MyComponent->GetUserWidgetObject();
 
 if (MyWidget)
 {
     // Do Stuff Here
 }

检查 Build.cs 文件 PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Slate", "SlateCore", "HeadMountedDisplay" }); 看是否添加“UMG"模块。

  • VR Does not Start in Standalone Game

创建UE4快捷方式到项目根目录下,然后右键属性,修改目标为:UE4Editor.exe路径  YourProject.uproject路径  -game -log

事例:E:\UE_4.21\Engine\Binaries\Win64\UE4Editor.exe D:\UE4\Project\FirstPersonProject.uproject -game -log

发布了40 篇原创文章 · 获赞 14 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/zhangmei126/article/details/101424697
今日推荐