在UE4引擎启动阶段会有一个Gather Data的阶段
把所有的资源全部都放入注册表当中。
入口如下:
FAssetDataGatherer::ReadAssetFile
其中会调用到如下代码
FPackageReader::EOpenPackageResult OpenPackageResult;
if ( !PackageReader.OpenPackageFile(AssetFilename, &OpenPackageResult) )
{
// If we're missing a custom version, we might be able to load this package later once the module containing that version is loaded...
// - We can only attempt a retry in editors (not commandlets) that haven't yet finished initializing (!GIsRunning), as we
// have no guarantee that a commandlet or an initialized editor is going to load any more modules/plugins
// - Likewise, we can only attempt a retry for asynchronous scans, as during a synchronous scan we won't be loading any
// modules/plugins so it would last forever
const bool bAllowRetry = GIsEditor && !IsRunningCommandlet() && !GIsRunning && !bIsSynchronous;
OutCanRetry = bAllowRetry && OpenPackageResult == FPackageReader::EOpenPackageResult::CustomVersionMissing;
return false;
}
如果出现了问题则会Gather失败,在Browser中将不会显示对应的资源。
通常无法显示有以下原因:
- Loader为空(EOpenPackageResult::NoLoader)
- 文件格式错误 (EOpenPackageResult::MalformedTag)
- 资源版本和引擎版本不匹配 (EOpenPackageResult::VersionTooOld 或者 EOpenPackageResult::VersionTooNew)
如果出现了其中任意一个错误,资源都不会显示。
在资源缓存过了一次之后,会将资源的注册表缓存在用户本地目录:
CachedAssetRegistry.bin
如果希望快速找到与引擎版本不符的资源,可以删除CachedAssetRegistry后再重新打开引擎。
如此就可以遍历所有的引擎资源。
在报错处添加log,报错如下: