找回密码
 立即注册
查看: 326|回复: 0

Unreal 游戏开发问题和解决方案笔记

[复制链接]
发表于 2023-7-7 10:20 | 显示全部楼层 |阅读模式
说明


  • 本文的目的在于记录、总结和分享 Unreal 游戏开发过程中遇到的问题和解决法子。
  • 本文所涉及内容具有局限性:对应的引擎版本为 UE4.27.2(默认) / UE5.2(个别) ,其问题在当前最新版本中不必然存在,其解决方案可能并非独一的、最正确的、很完善的,乃至可能已经掉效了。
  • 个人经验,仅供参考。如有谬误,欢迎指出。
环境相关


  • IncrediBuild无法访谒其他agent,提示:This agnet is not subscribed... 及 License is invalid。

    • 打点员那边没subscribe这台机器

  • DDC 不生成 GSM 和 MAT 或生成的 UDD 很少。

    • 查抄是否设置并已经生成了完整的 PAK 型的 DDC 。

  • 游戏工程改了代码后生成,但是操作很快结束,也没有真正从头生成。

    • 用VS2017而不是2019来编译。

  • 编译太耗时

    • 可以考虑引擎和游戏工程放在SSD、使用Incredibuild、共享DDC等

  • UE4 VS 中代码编译后需要重启UE4才生效

    • 不在 VS 中编译,在UE4 中 editor preference 里启用 live coding,通过 live coding 快捷键来编译代码。

  • 筹谋和美术,在非C++工程,加了个插件,工程没有源码,如何让插件在新工程生效

    • 先直接运行 uproject 打开工程,再随便创建一个C++脚本,这样就有 sln 了,然后再双击运行 uproject ,提示插件版本纷歧致是否从头build时,确定,即可从头生成。

  • LogDerivedDataCache: Display: Failed to cache data. Maximum cache size reached. CurrentSize 524285 kb / MaxSize: 524288 kb

    • 在 Engine\Config\BaseEngine.ini 中可以配置 game project下的 \DerivedDataCache\Boot.ddc 的大小,这用于加速启动。

  • A 工程使用 B 引擎而不用安装C++

    • 把 A 工程提示引擎版本不合错误的插件的 buildid 改成 B 引擎的 buildid

  • UE4时不时的抽筋(比如log console随便的点击)时的exception咋措置?测验考试过卸载搜狗换百度,也会呈现,感觉跟windows有关啊。。

    • 可能是输入法冲突了,测验考试卸载第三方输入法,使用自带的输入法如微软输入法

  • Jenkins 打的包俄然大了很多(如一倍),编纂器下打的包却没这个问题

    • 可能是Jenkins打包时 少了个-pak参数导致新包大

  • PS4上鼠标键盘不成用时如何输入command命令到UE控制台

    • 可通过PS4 console 下的 input 框。

  • 有的同事的UE4工程提示shared ddc 没开启,查看log发现其无法访谒DDC处事器地址。但其他人可以访谒。

    • 可在该同事机器上做如下设置:当地组策略 - 计算机配置 - 打点模板 - 网络 - Lanman 工作站 - 启用不安全的宾客登录

  • 请问如安在配置或代码中让Test build 默认启动就带 -llm?

    • 在 ProjectTarget.cs​ 中添加如下代码:

if (Configuration == UnrealTargetConfiguration.Test)
{
   GlobalDefinitions.Add(””LLM_AUTO_ENABLE=1””);
}

  • UE hotfix 的查找和应用(引擎崩溃和问题等的修正查找和应用)

    • hotfix 查找: https://forums.unrealengine.com/t/5-0-2-hotfix-released/566149
    • 获取对应的改削: https://github.com/search?q=repo:EpicGames/UnrealEngine+keyword&type=commits

编译和打包错误


  • ”UFunction %s.%s cannot convert argument %s to %s”

    • callback 的参数用 str

  • cook时发生 Critical error: 但是看不到详细的仓库

    • 可在编纂器下用 debuggame cook 尝尝,以便看到详细仓库

  • 打PS包呈现 error: use of typeid requires -frtti ,即便对模块启用 bUseRTTI = true; 也无效



1f2q749nclvrqm5rggtkpglg03.png


  • unresolved external symbol ”public: void cdecl FReflectionInspectModule::Inspect(class FString)” (?Inspect@FReflectionInspectModule@@QEAAXVFString@@@Z) referenced in function ”private: static void cdecl FEditorExtensionsHelper::InspectActors(void)” (?InspectActors@FEditorExtensionsHelper@@CAXXZ)

    • 模块要包含想要用方式的另一个模块,另一个模块要有XXX_API,其方式等才能被其他模块引用

  • 关于部门 inner 代码在崩溃调试时看不到仓库

    • 打开对应模块的 *.Build.cs 文件(如 PS4RHI.Build.cs),在构造函数中加上 OptimizeCode = CodeOptimization.Never; 同时注释掉对应的 inline

  • UE4 4.27 的git源码编译错误:RemoteControlPreset.cpp(1870): fatal error C1001: Internal compiler error.



2ljdd24nh062crd4oqkn9jpjqq.png



4o2bk82uj9grntqqa2m674e59o.png


  • Exhausted all retries! ProjectName D:\poject_name\client_trunk\Intermediate\ProjectFiles\EXEC 1

    • 一般是因为UE或游戏工程、插件等被其他进程占用了,比如多开了UE、正在调试同一个工程等

  • static 变量如下提示: 无法解析的外部符号 ”private: static class TSharedPtr UAnalayzerTicketBPLibrary::ExecutingNotification” (?ExecutingNotification@UAnalayzerTicketBPLibrary@@0V?$TSharedPtr@VSNotificationItem@@$0A@@@A)

    • 把对应的static 变量放到cpp中

  • 打包掉败:Ensure condition failed: NumBytes == Strings.Num() [File:F:/ProjectName_Build_Client_Engine/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp] [Line: 3336]

    • 对打包的cook进行debug,可以看到是 D:\poject_name\client_trunk\Intermediate\AssetRegistryCache 的某个bin出问题了,删除这些大的bin后从头打包即可

  • 编纂器没法打开,提示 LogAssetRegistry: Error: Failed to open file for write ../.../../svn_poject_name/Intermediate/CachedAssetRegistry.bin.tmp

    • 从能打开的机器中拷贝一份intermediate 和 ddc 替换之。

  • UE4源码编译报错 (将“_NOEXCEPT_TYPES_SUPPORTED”定义为预措置器宏,用“0”替换“#if/#elif” UE4 C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\winrt\wrl\event.h 211)

    • 更多错误:错误 CS0234 定名空间“Windows”中不存在类型或定名空间名“Management”(是否缺少法式集引用?) HoloLens.Automation
    • https://blog.csdn.net/DSK_981029/article/details/124852922
    • 关键在于修正 Windows.winmd 的引用

  • 请问cook下shader编译的问题要如何debug呢?想知道具体犯错的仓库和问题

    • 可以尝尝如下命令:

[ConsoleVariables]
r.ShaderCompiler.AllowDistributedCompilation=0 ;;禁用xge

[DevOptions.Shaders] bAllowAsynchronousShaderCompiling=True ;;禁用异步shader编译


  • ERROR: Non-editor build cannot depend on non-redistributable modules.

    • 详细错误

      • ProcessResult.StdOut:   Writing manifest to YouEngineLocalPath\Engine\Intermediate\Build\Manifest.xml                        ProcessResult.StdOut:   ERROR: ERROR: Non-editor build cannot depend on non-redistributable modules. D:\poject_name\client_trunk\Binaries\Win64\ProjectName-Win64-Shipping.exe depends on 'Settings'.                        ProcessResult.StdOut:          Dependant modules 'YourPluginName'                        ProcessResult.StdOut:   ERROR: Non-editor build cannot depend on non-redistributable modules.

    • Dependant modules (“YourPluginName”)中的模块依赖了 'Settings',在非 shipping 下没问题,但是在 shipping 下会编译不外。 把 'Settings' 放在 if (Target.bBuildEditor) 之内就好      LogShaderCompilers: Error: Expecting ShaderCompileWorker Single Jobs 83, got 0 instead! Forgot to build ShaderCompileWorker?         *      以PS5打包为例,把引擎下 Engine\Binaries\Win64\PS5 目录里 ShaderCompileWorker-PS5ShaderFormat.dll 和 ShaderCompileWorker-PS5ShaderFormat.pdb 删除后从头打包能成功

  • ERROR: Failed to build ””YouEngineLocalPath/Engine/Programs/AutomationTool/Saved\UATTempProj.proj””

    • 详细错误

      • Cook 错误且乱码:
      • Took 3.1388531s to run MSBuild.exe, ExitCode=1                   ERROR: Failed to build ””YouEngineLocalPath/Engine/Programs/AutomationTool/Saved\UATTempProj.proj””:                           BuildCMakeLib.Automation.cs(45,54): error CS1002: Ӧ     ;                      poject_name/client_trunk/Saved/Logs/Cook_20230309_171015.log -compile                  Dependencies are out of date. Compiling scripts....                      BuildCMakeLib.Automation.cs(45,54): error CS1002: Ӧ     ; [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                      BuildCMakeLib.Automation.cs(45,87): error CS1519:  ࡢ ṹ  ӿ  Ա     еı ǡ (    Ч [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                      BuildCMakeLib.Automation.cs(51,57): error CS1002: Ӧ     ; [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                      BuildCMakeLib.Automation.cs(51,90): error CS1519:  ࡢ ṹ  ӿ  Ա     еı ǡ (    Ч [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                      BuildCMakeLib.Automation.cs(71,37): error CS1002: Ӧ     ; [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                      BuildCMakeLib.Automation.cs(71,44): error CS1519:  ࡢ ṹ  ӿ  Ա     еı ǡ ;    Ч [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                      BuildCMakeLib.Automation.cs(92,49): error CS1002: Ӧ     ; [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                      Took 3.1388531s to run MSBuild.exe, ExitCode=1                  ERROR: Failed to build ””YouEngineLocalPath/Engine/Programs/AutomationTool/Saved\UATTempProj.proj””:                           BuildCMakeLib.Automation.cs(45,54): error CS1002: Ӧ     ; [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                           BuildCMakeLib.Automation.cs(45,87): error CS1519:  ࡢ ṹ  ӿ  Ա     еı ǡ (    Ч [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                           BuildCMakeLib.Automation.cs(51,57): error CS1002: Ӧ     ; [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                           BuildCMakeLib.Automation.cs(51,90): error CS1519:  ࡢ ṹ  ӿ  Ա     еı ǡ (    Ч [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                           BuildCMakeLib.Automation.cs(71,37): error CS1002: Ӧ     ; [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]                           BuildCMakeLib.Automation.cs(71,44): error CS1519:  ࡢ ṹ  ӿ  Ա     еı ǡ ;    Ч [YouEngineLocalPath\Engine\Source\Programs\AutomationTool\Scripts\AutomationScripts.Automation.csproj]

    • 解决法子:在 rider 里 rebuild AutomationTool solution 即可。注意是 AutomationTool 而不是 Automation 。

  • UE4编译代码后运行崩溃,看仓库是 Error: Ensure condition failed: InParent == nullptr || !InParent->IsAttachedTo(this) [File:D:/.../SceneComponent.cpp]

    • UE4引擎的hotload有bug,不要在UE4中编译代码,在VSCode等中编译。
    • UE4不要编译代码,用UE4生成VS工程,用生成的VS工程来编译代码。

  • UE4打开工程进度到90%多的时候提示“UE4Editor-GeometryMode.dll”相关的报错而导致打开工程掉败

    • 删除 DerivedDataCache 、 Intermediate 、 Saved ,还原非必要改削后,从头选择对应的UE,编译代码,打开UE后,重启一下UE。

  • Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Generator

    • 有引用对应的头文件没有include,include对应的头文件即可。

  • 29>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(49,5): error MSB3073: 命令“E:\YouLocalPath\UE4\Epic\Engine\Build\BatchFiles\Rebuild.bat -Target=”OldProjectAEditor Win64 Development -Project=\”E:\YouLocalPath\game\trunk\OldProjectA.uproject\”” -Target=”ShaderCompileWorker Win64 Development” -WaitMutex -FromMsBuild”已退出,代码为 -1。

    • 封锁VS和UE,从头切换一下工程的打开UE,再打开VS编译

  • 关卡所有的灯光烘焙都build不了 。呈现这个提示 Lighting build failed. Swarm failed to kick off.Compile Unreal Lightmass

    • 打包机上要vs手动编译一下lightmass

  • incredibuild无效,提示如下:License is invalid:License infornation is invalid. Please try reloading your license file using the Coordinator Monitor application on the Coordinator nachine, or reinstall IncrediBuild. l This build will run in standalone mode

    • agent settings 里设置computer 等信息

  • 遇到路径过长编译不外的问题,有没有什么解决方案,改短项目路径是有用的,但是每次都需要从头编译,请问还有其他方式可以解决吗?

    • 详细错误:

      • D8049无法执行”C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\c1xx.dll”:命令行太长,无法适应调试记录

    • 在 xxx.build.cs 文件中添加:bLegacyPublicIncludePaths = false;
    • 或者:重启机器
    • 或者:在 Build.cs 里加个空格 从头编译

  • Error LNK1104 cannot open file 'D:\ProjectName_ENGINE\Engine\Binaries\Win64\PS4\UE4Editor-PS4ShaderFormat.dll'

    • 删除 Engine\Binaries\Win64\ 后从头编译 UE 即可。

  • 运行游戏提示Blueprint编译错误,导入python提示utf-8编码错误,其他人不会

    • 独立编译引擎后再编译项目,可能是多个项目用同一个引擎的原因

  • 打包报错提示在一个很久不改削的插件上 KawaiiPhysics

    • 看看是否是引擎改削了,是的话, (通过 VS )Rebuild (game)Project 后再打包

引擎使用


  • worldsettings中的gamemode里设置了defaultpawnclass为A,运行游戏时主角玩家倒是B。

    • 启动场景中的这个B的Pawn被设置为AutoPossessPlayer Player 0了。

  • 编纂器下改削蓝图后运行会自动编译蓝图

    • Editor Preferences / Level Editor -Play / Play in Editor / Auto Recompile Blueprints

  • 从A项目拷贝一个工程改名为 B 等后,无法启动

    • 需要做重定向:

      • Project/Config/DefaultEngine.ini:


[CoreRedirects]
+ClassRedirects=(MatchSubstring=True,OldName=””/Script/OldProject””,NewName=””/Script/NewProjectName””)
+EnumRedirects=(MatchSubstring=True,OldName=””/Script/OldProject””,NewName=””/Script/NewProjectName””)
+FunctionRedirects=(MatchSubstring=True,OldName=””/Script/OldProject””,NewName=””/Script/NewProjectName””)
+StructRedirects=(MatchSubstring=True,OldName=””/Script/OldProject””,NewName=””/Script/NewProjectName””)

  • CoreRedirects 对 DataTable Blueprint 等资源无效

    • 用 PackageRedirects 而不是 ClassRedirects 等措置资源。

  • lightmap 从头build掉败

    • 查抄是否有 lightmass 相关报错,是否已经 build UnrealLightmass

  • GameThread 下的 FrameTime

    • FrameTime 是 STAT_FrameTime 变量感化域内的时间统计,此中 Self 是指除了 ChildrenScope 以外所有时间的总和,并不暗示某一个具体的函数。
    • 具体需要定位的话,可以通过使用 QUICK_SCOPE_CYCLE_COUNTER(STAT_XXXScope_XXXFunction); 添加几个快速埋点,来确定更明确的位置。
    • 此外您可以测验考试以下使用 Unreal insight​,可以看到这些scope的执行挨次,可以更快定位出热点再哪里。时间的统计也更加准确一些。

  • CPU Stall - Wait for Event/Sleep …

    • CPU Stall means this thread is mainly idle for these time since the thread cannot step forward to the next frame until all the thread finishes this frame, which means if a thread finishes it is work too early, it has to wait, which is the event Wait for Event. In another case, when it shows CPU Stall - Sleep, that means that thread is paused and sleeping, doing nothing.

  • 场景无法保留

    • 是否打开了多个同样的工程?

  • 模型上的贴图显示异常,有明暗纷歧的斑点

    • 查抄是否光照贴图没烘焙(把灯光改成动态的可以立刻看到效果)

  • 用 CoreRedirect 做了 目录的 package 重定向后引用视图不好用

    • 还要用 ResavePackages 的 commandlet 对资源做从头的保留,之后再删除重定向器。

  • UE4 build 后 使用 SessionFrontend profiler

    • 用命令行 stat startfile/stopfile

  • 如安在重定向后删除重定向器以提升速度

    • 重定向保留一下,保留之后删除重定向设置。

  • 请问 Editor Unity Blueprint 里如何获取 Content 里选中物体上所有的 ActorComponent ?测试发现 GetSelectedAssets 返回的 object 无法转换为 actor 。

    • Cast<UBlueprint>(Object)->GeneratedClass->GetDefaultObject() Object->MarkPackageDirty();

  • VS工程在编纂器代码添加删除之间切换后无法编译通过

    • rebuild工程,或者封锁VS,从头生成工程。

  • UE4打包后一些引用莫名丢掉

    • 添加到 AddToRoot 避免被GC

  • 从A项目migrate umap 到 B项目后,B项目中资源打点器里有这个资源但是content下不成见。

    • 在A项目中右击关卡 - “拷贝引用”。 在B项目中,在缺少地图的文件夹中执行 CTRL V 粘贴。 半晌之后,关卡呈现并正确打开。

  • 右键uproject文件不显示三菜单 - launch game、gegerate vs project files 和 Switch Unreal Engine version

    • 右键uproject 选择 Unreal Engine而不是默认的UE图标的UE4,之后就正常显示了

  • level加载完毕后,人物往下掉出地面,无报错

    • OpenLevel时传入的levelname要用 PackageName 而不是 ObjectPath ,即用 /Game/AssetName 而不是 /Game/AssetName.AssetName 。 猜测底层加载的时候,level包里有一些其它的依赖资源

  • 打包后 culldistancevolume无效

    • 改削 UWorld::UpdateCullDistanceVolumes ,改成 !bUpdatedDrawDistances && (!FMath::IsNearlyEqual(PrimitiveComponent->LDMaxDrawDistance, PrimitiveComponent->CachedMaxDrawDistance) && !GIsCookerLoadingPackage)

  • Unreal Insights 捕捉的 PS4 的性能数据里没有显示

    • 底部(新连接(New Connection))拥有尝试性 连接(Connect) 按钮和文本输入字段,可在此中输入正在进行的会话IP。 此功能主要用于游戏主机,尚在开发中,可能不不变。未来版本会有此功能的进一步迭代。 目前独一的保举法式为: 启动项目并为项目使用 -tracehost=%ADDRESS% 命令行选项,然后启动 Unreal Insights 东西。
    • -trace -tracehost=X.X.X.X

  • SessionFrontend Profiler ,仓库过滤查找关键词有时候找到的成果不合错误

    • 关键词如有空格,用双引号把整个关键词包裹起来再过滤。如:”Blueprint Latent Actions”

  • Mobile Preview ES3.1 (PIE) black 移动预览黑屏” ,编纂器屏幕上其实有红色提示

    • 应用配置:

[/Script/Engine.RendererSettings]       
r.RayTracing.Skylight=False       
r.SupportStationarySkylight=False       
r.SupportSkyAtmosphere=False       
r.SupportSkyAtmosphereAffectsHeightFog=False使用技巧


  • 蓝图线交叉不美不雅观

    • 添加“Add Reroute Node”节点来指定线路。

  • 蓝图中设置按序执行流程

    • 添加 Sequence 节点。

  • % 节点取模、switch on int 节点通过 int 来进入分歧节点
  • 怎么快速选到界面里的某个UI?

    • 可使用 Widget Reflector

  • 如安在运行时在game视图进行场景漫游

    • 菜单栏选择 Eject

  • UE4 output log 显示时间戳(Timestamp)

    • UE Preferences -> General -> Appearance -> Log Timestamp Mode

  • 如安在运行时选择物体

    • You can run in editor window, shift+f1, press pause and press eject. Then your editor controlls will be enabled and you will be able to navigate the scene.
    • 或者说:编纂器窗口运行,按F8,进入编纂模式

  • Content Browser 查找不在某路径下的资源

    • 高级搜索:PATH != ”/Game/FoldA/” AND PATH != ”/Game/Content/FoldB”

  • UE4 content 中如何显示 developers 文件夹

    • Content 右下角 View Options 中勾选 Show Developers Content

  • DataTable的Row里的信息很多,想批量改削替换

    • 可直接复制整行(CTR+C)到文本编纂器替换后再到DataTable中粘贴(CTR+V)回来

  • 请问,PIE下能显示这个相机视锥么?我如是设置无效(非play时有效)

    • ”需要改削一下引擎代码,UDrawFrustumComponent 构造函数中 bHiddenInGame 改为 false 然后在 PIE 时可以通过 showflag.camerafrustum 1/0 打开封锁”

  • 如安在TEST包下查看tick - dumpticks

    • 首先通过 ~ 打开控制台,按2次切换到控制台界面。然后输入 dumpticks ,然后通过 FN + PgUp 来网上查看更多的tick 。

  • 显示Mesh的详细信息

    • Character -> Mesh -> Detailed

  • 让某些属性的可编纂与否依赖另一个属性

    • Meta=(EditCondition = ”bOverrideStartGridPosition”)

  • 请问怎么设置才能让指定Plugin不参与指定平台的编译和打包?UPlugin里的 WhitelistPlatforms、BlacklistPlatforms、SupportsTargetPlatform、EnabledByDefault 仿佛都不行,

    • 是不是被其他模块依赖了,导致进包了

  • Datatable 里的部门项不成编纂

    • UPROPERTY(EditAnywhere,...

  • 解除帧率限制
t.MaxFPS 1000
r.VSync 0

  • 查找中文字符

    • 正则:(”.[\u4E00-\u9FA5]+)|([\u4E00-\u9FA5]+.”)

代码相关


  • 改削python代码后如安在UE4游戏中生效

    • 改削python代码后,UE4中提示有资源有改削是否import,import后即可生效。
    • 可通过重启UE4让它生效;

  • Uproperty 中的 category 不生效

    • category 对 notifystate等无效,对actor有效。

  • Python 语法和定义提示

    • VSCode 插件:PyLance

  • python 文件和类改名后的重定向

    • 比如把 Content\Script\project_name\project_name_game_instance.py 的 PyXProjectNameGameInstance 重定向为 Content\Script\project_name\project_name_game_instance.py 的 PyProjectNameGameInstance 方式如下:

      • CoreRedirects 中添加

        • +PackageRedirects=(MatchSubstring=True,OldName=”/Script/UnrealEnginePython/project_name/project_name_game_instance.PyXProjectNameGameInstance”,NewName=”/Script/UnrealEnginePython/project_name/project_name_game_instance.PyProjectNameGameInstance”)



  • UE4 源码里找不到蓝图方式 Async Load Class Asset

    • 空格不要漏。

  • 请问C++中如何添加一个Blueprint可用的、带回调的函数?直接用 DECLARE_DELEGATE 会报错“Unrecognized type &#39;FAsyncLoadDelegate&#39; - type must be a UCLASS, USTRUCT or UENUM”

    • DECLARE_DYNAMIC_DELEGATE 可以参考下 K2_SetTimerDelegate 是 DECLARE_DELEGATE 没法序列化,非dynamic的只能C++用”

  • Blueprint中调用 python 中自定义的静态方式

    • python担任 BlueprintFunctionLibrary

  • python 中使用C++中的enum

    • C++中enum上标识表记标帜了 UENUM( BlueprintType ) 即可,可能python中不会有提示,但是import后Blueprint中会生效

  • C++中的 DECLARE_DYNAMIC_DELEGATE_OneParam 回调在 python 中不执行

    • 注意 python 中回调地址的类必需是 actor,生成方式必需是 spawn_actor 而不能是 new_object

  • python 中获取 enum 的 str 形式

    • 通过 EYouEnum.enum_names() 获取到所有字符串的列表,再通过 int index 获取到具体index对应的字符串值。

  • 担任自 ActorBase 的 Python 类的 ReceiveBeginPlay 不执行了

    • 蓝图子类重写了相关方式,没有调用父方式,则可能呈现类似情况,
    • 蓝图子类方式中断开了对父类相关方式的调用后可呈现问题

  • 组件在Blueprint中不识别

    • UCLASS(meta=(BlueprintSpawnableComponent))

  • exec 不显示help,subsystem 顶用 exec 执行无效

    • 用 subsystem + iconsolemanager 来实现GM 控制台指令系统

  • Plugin B 中的某个担任自 FTableRowBase 的struct 在 Plugin A 中总是不成用

    • 改削 Plugin B 的 uPlugin 文件中的 LoadingPhase”: ”PostEngineInit”
    • 概略意思是时机问题

  • TempDataTable->FindRow 找不到,返回nullptr

    • rowname 如果传的是assetfullname,会把空格替换掉

  • 编纂器下timer有时候不执行回调

    • 用 GEditor->GetTimerManager()->SetTimer

  • setting 中给 UPROPERTY 设置 AdvancedDisplay 后,编纂器中没法隐藏

    • 对应分类必需有一个没有 AdvancedDisplay 属性的;编纂器配置的右上角设置中必需没开启“显示所有高级隐藏项目”

  • 计时器 settimer 回调执行的时间不合错误,总是比设定的时间快一倍

    • 查抄是否设置了 slomo 为 2,看控制台日志

  • 编纂器下对已加载资源进行卸载和内存释放

    • UEditorLoadingAndSavingUtils::UnloadPackages 这个接口是可以做到在编纂器下对已经加载的资源进行卸载和内存释放的,但是有的资源可能还是无法卸载干净,因为其可能被其他资源引用,可通过API查询被什么应用了 `

ReferencesToObject = UEngine::FindAndPrintStaleReferencesToObject(LoadObject, EPrintStaleReferencesOptions::Display);
const FReferenceChainSearch RefChainSearch(   InObject, EReferenceChainSearchMode::Longest/ | EReferenceChainSearchMode::PrintResults/);

  • ForeachLoop等改变了传入的类型后后续的操作掉败,提示访谒空 access none

    • 改削了类型后,后续的依赖之前的类型的都要删除从头获取

调试相关


  • 启动游戏工程后崩溃,想要 fulldump

    • 命令行或快捷方式启动游戏工程,添加 -fullcrashdump 。
    • 如:”E:\YouLocalPath\YouLocalPath\Engine\Binaries\Win64\UE4Editor.exe” ”F:\YouLocalPath\OldProjectA.uproject” -logtimes log=Game0.log -fullcrashdump

  • Visual Studio打开游戏工程,在引擎内设置断点,无法命中某些断点,提示源码不匹配

    • 打开引擎VS工程,clean后rebuild,再去打开游戏VS工程断点。

  • 运行时查看动画状态机等的即时状态

    • 在 WorldOutline 中选中方针 actor 后,在 detail 中选择对应的 mesh , 打开后,选择 Blueprint 且在左侧 skeleton 左侧选择当前运行时要调试的角色,即可

  • 用vscode attach 调试 python时,改了python代码后,无法从头attach 上,需要重启UE

    • 改削python代码无需断开vscode,UE中 import后即时生效的

  • VS UE 部门代码被跳过无法进入、部门变量被裁减掉不成见

    • 把编译模式从 development editor 改成 debug editor。

  • 如何通过 vs attach 到ps4法式上对工程代码进行 debug

    • vs 的 solution platforms 里选 PS4,attach to process 界面 connection type 里选 ps4 target ,connect target 里选方针机器 ip,process 面板列表里选方针法式(如eboot.bin)

  • rider debug 调试 Standlone 模式的 ue pie

    • run -> attach to process 选择方针法式即可

  • UE 打开游戏工程,UE引擎中的源码断点无法命中

    • 查抄是否相关断点在 FORCEINLINE 的代码中

  • 在C++代码中打印输出调用仓库

    • FDebug::DumpStackTraceToLog(ELogVerbosity::Error);

  • ShaderCompilerCommon.cpp 中 CompileOfflineMali 里加的日志不输出,也无法被断点到,但改削的代码能生效

    • 该模块被 ShaderCompileWorker 引用(见 ShaderCompileWorker.Build.cs )
    • ShaderCompileWorker 设置了默认不显示日志(见 ShaderCompileWorkerTarget 中的 ALLOW_LOG_FILE)
    • ShaderCompileWorker 的日志输出在本身的目录而不是项目或引擎默认日志文件中 (Engine\Programs\ShaderCompileWorker\Saved\Logs)
    • 没法在游戏进程被断点到是因为 ShaderCompileWorker 属于分歧的进程,可以新开工程对其进行attach

声明:本文来自公众号:Unity 与Unreal 游戏开发(GameDevLearning),转载请附上原文链接及本声明。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-4 20:32 , Processed in 0.177548 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表