UE – UGCExample 项目打包后 Assertion failed

表现

Assertion failed: !FPaths::IsRelative(Dir) [File:/Engine/Source/Runtime/Projects/Private/ProjectDescriptor.cpp] [Line: 337] 
../../../UGCExample/../RemappedPlugins/ is not an absolute path

解决方案

将 ProjectDescriptor.cpp 第 143 行处修改:

// If this is a packaged build and there are additional directories, they need to be remapped to the packaged location
if (FPlatformProperties::RequiresCookedData() && AdditionalPluginDirectoriesValue->Num() > 0)
{
    AdditionalPluginDirectories.Empty();
    FString RemappedDir = FPaths::ProjectDir() + TEXT("../RemappedPlugins/");

    // Fixed assertion failed
    RemappedDir = FPaths::ConvertRelativePathToFull(RemappedDir);

    AddPluginDirectory(RemappedDir);
}

分析

AddPluginDirectory 函数只接受绝对路径,但是 FPaths::ProjectDir() 有时返回相对路径,导致 RemappedDir 合成出来为相对路径,被 AddPluginDirectory 的 check 检测引发崩溃。
可以通过使用函数 FPaths::ConvertRelativePathToFull 将 RemappedDir 强制转换为绝对路径解决。

UE4是成熟的商业引擎

2 thoughts on “UE – UGCExample 项目打包后 Assertion failed

发表评论