前言
引擎版本 UE 5.32源码
需求:打包时将非uasset资产(如Lua脚本)单独打入指定chunk包
遇到过的问题:
- PakFileRules文件被排除
- 设置了指定的chunkId但无效
流程
修改DefaultGame.ini,添加允许的配置文件目录
对AutomationTool\AutomationUtils\DeploymentContext.cs进行修改
对Scripts/CopyBuildToStagingDirectory.Automation.cs 进行修改
private struct PakFileRules
{
// Name of config section
public string Name;
// Combined filter from all +Files= entries
public FileFilter Filter;
// An alternative and efficient way to match files
public HashSet<string> ExactFileMatches = new();
// To use exact file match or file filter
public bool bUseExactFilePathMatch = false;
// Rather to exclude entirely from paks
public bool bExcludeFromPaks = false;
// Rather to allow overriding the chunk manifest, if false will only modify loose files
public bool bOverrideChunkManifest = false;
// Whether pak file rule is disabled
public bool bDisabled = false;
// List of pak files to use instead of manifest
public List<string> OverridePaks = new();
// Whether this rule is defined for content-on-demand
public bool bOnDemand = false;
public bool bStageLoose = false;
// Encryption key
public string EncryptionKeyGuid = "";
public PakFileRules()
{
Name = "";
Filter = new FileFilter();
}
public static bool IsMatch(PakFileRules PakRules, KeyValuePair<string, string> StagingFile)
{
bool bMatched = !PakRules.bDisabled &&
((!PakRules.bUseExactFilePathMatch && PakRules.Filter != null && PakRules.Filter.Matches(StagingFile.Key)) ||
(PakRules.bUseExactFilePathMatch && PakRules.ExactFileMatches != null && PakRules.ExactFileMatches.Contains(StagingFile.Value)));
return bMatched;
}
};
/// <summary>
/// Reads Default/BasePakFileRules.ini and returns all PakFileRules objects that apply for this deployment
/// </summary>
/// <param name="Params"></param>
/// <param name="SC"></param>
private static List<PakFileRules