修改 DDC 的路径

源码版与安装版引擎的路径有区别:

BaseEngine.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[DerivedDataBackendGraph_Fill_Seattle]
MinimumDaysToKeepFile=7
Root=(Type=KeyLength, Length=120, Inner=AsyncPut)
AsyncPut=(Type=AsyncPut, Inner=Hierarchy)
Hierarchy=(Type=Hierarchical, Inner=Boot, Inner=Pak, Inner=EnginePak, Inner=Local, Inner=Seattle)
Boot=(Type=Boot, Filename="%GAMEDIR%DerivedDataCache/Boot.ddc", MaxCacheSize=512)
Local=(Type=FileSystem, ReadOnly=false, Clean=false, Flush=false, PurgeTransient=true, DeleteUnused=true, UnusedFileAge=34, FoldersToClean=-1, Path=%ENGINEDIR%DerivedDataCache)
Seattle=(Type=FileSystem, ReadOnly=false, Clean=false, Flush=false, DeleteUnused=true, UnusedFileAge=23, FoldersToClean=10, MaxFileChecksPerSec=1, Path=?EpicSeaDDC, EnvPathOverride=UE-SharedDataCachePath_Seattle)
Pak=(Type=ReadPak, Filename="%GAMEDIR%DerivedDataCache/DDC.ddp")
EnginePak=(Type=ReadPak, Filename=%ENGINEDIR%DerivedDataCache/DDC.ddp)

[InstalledDerivedDataBackendGraph]
MinimumDaysToKeepFile=7
Root=(Type=KeyLength, Length=120, Inner=AsyncPut)
AsyncPut=(Type=AsyncPut, Inner=Hierarchy)
Hierarchy=(Type=Hierarchical, Inner=Boot, Inner=Pak, Inner=CompressedPak, Inner=EnginePak, Inner=EnterprisePak, Inner=Local, Inner=Shared)
Boot=(Type=Boot, Filename="%ENGINEUSERDIR%DerivedDataCache/Boot.ddc", MaxCacheSize=512)
Local=(Type=FileSystem, ReadOnly=false, Clean=false, Flush=false, PurgeTransient=true, DeleteUnused=true, UnusedFileAge=34, FoldersToClean=-1, Path="%ENGINEVERSIONAGNOSTICUSERDIR%DerivedDataCache", EditorOverrideSetting=LocalDerivedDataCache)
Shared=(Type=FileSystem, ReadOnly=false, Clean=false, Flush=false, DeleteUnused=true, UnusedFileAge=10, FoldersToClean=10, MaxFileChecksPerSec=1, Path=?EpicDDC, EnvPathOverride=UE-SharedDataCachePath, EditorOverrideSetting=SharedDerivedDataCache)
Pak=(Type=ReadPak, Filename="%GAMEDIR%DerivedDataCache/DDC.ddp")
CompressedPak=(Type=ReadPak, Filename="%GAMEDIR%DerivedDataCache/Compressed.ddp", Compressed=true)
EnginePak=(Type=ReadPak, Filename=../../../Engine/DerivedDataCache/Compressed.ddp, Compressed=true)
EnterprisePak=(Type=ReadPak, Filename=../../../Enterprise/DerivedDataCache/Compressed.ddp, Compressed=true)

源码版的引擎存在于 Engine/DerivedDataCache 与项目的 DerivedDataCache 目录下。
安装版引擎的则位于以下几个路径中:

  • %ENGINEUSERDIR%DerivedDataCache/Boot.ddc
  • %ENGINEVERSIONAGNOSTICUSERDIR%DerivedDataCache
  • %GAMEDIR%DerivedDataCache/DDC.ddp
  • ../../../Engine/DerivedDataCache/Compressed.ddp
  • ../../../Enterprise/DerivedDataCache/Compressed.ddp

这几个路径规则的真实路径:

Runtime/Core/Private/Misc/ConfigCacheIni.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
static const FConfigExpansion* MatchExpansions(const TCHAR* PotentialVariable)
{
// Allocate replacement value strings once
static const FConfigExpansion Expansions[] =
{
FConfigExpansion(TEXT("%GAME%"), FString(FApp::GetProjectName())),
FConfigExpansion(TEXT("%GAMEDIR%"), FPaths::ProjectDir()),
FConfigExpansion(TEXT("%ENGINEDIR%"), FPaths::EngineDir()),
FConfigExpansion(TEXT("%ENGINEUSERDIR%"), FPaths::EngineUserDir()),
FConfigExpansion(TEXT("%ENGINEVERSIONAGNOSTICUSERDIR%"), FPaths::EngineVersionAgnosticUserDir()),
FConfigExpansion(TEXT("%APPSETTINGSDIR%"), GetApplicationSettingsDirNormalized()),
};
// ...
}

可以在 BaseEngine.ini 中修改 DDC 的路径占位符,替换为上面的可选路径。

注意:EngineUserDirEngineVersionAgnosticUserDir 在安装版与源码版上也有区分:

Runtime/Core/Private/Misc/Paths.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
FString FPaths::EngineUserDir()
{
if (ShouldSaveToUserDir() || FApp::IsEngineInstalled())
{
return FPaths::Combine(FPlatformProcess::UserSettingsDir(), *FApp::GetEpicProductIdentifier(), *FEngineue_version::Current().ToString(EVersionComponent::Minor)) + TEXT("/");
}
else
{
return FPaths::EngineDir();
}
}

FString FPaths::EngineVersionAgnosticUserDir()
{
if (ShouldSaveToUserDir() || FApp::IsEngineInstalled())
{
return FPaths::Combine(FPlatformProcess::UserSettingsDir(), *FApp::GetEpicProductIdentifier(), TEXT("Common")) + TEXT("/");
}
else
{
return FPaths::EngineDir();
}
}

默认情况下,如果要完全清理系统中的 DDC 缓存,需要清理以下路径:

1
2
3
Engine\Engine\DerivedDataCache\*
ProjectName\DerivedDataCache\*
C:\Users\username\AppData\Local\UnrealEngine\*

可以使用以下 cmd 命令:

1
2
3
echo y|del Engine\DerivedDataCache
echo y|del ProjectName\DerivedDataCache
echo y|del C:\Users\username\AppData\Local\UnrealEngine

类似问题: