mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-06-11 13:23:54 +00:00
perf: guard manifest duplicate-key checks behind UNITY_EDITOR || DEBUG
This commit is contained in:
@@ -264,10 +264,12 @@ namespace YooAsset
|
|||||||
manifest.AssetList.Add(packageAsset);
|
manifest.AssetList.Add(packageAsset);
|
||||||
|
|
||||||
// 注意:我们不允许原始路径存在重名
|
// 注意:我们不允许原始路径存在重名
|
||||||
|
// 说明:清单是构建期生成的可信数据,重名只会因构建错误产生,仅在开发期校验即可,发行版省去一次哈希查找。
|
||||||
string assetPath = packageAsset.AssetPath;
|
string assetPath = packageAsset.AssetPath;
|
||||||
|
#if UNITY_EDITOR || DEBUG
|
||||||
if (manifest.AssetDic.ContainsKey(assetPath))
|
if (manifest.AssetDic.ContainsKey(assetPath))
|
||||||
throw new System.Exception($"AssetPath have existed : {assetPath}");
|
throw new System.Exception($"AssetPath have existed : {assetPath}");
|
||||||
else
|
#endif
|
||||||
manifest.AssetDic.Add(assetPath, packageAsset);
|
manifest.AssetDic.Add(assetPath, packageAsset);
|
||||||
|
|
||||||
// 填充AssetPathMapping1
|
// 填充AssetPathMapping1
|
||||||
@@ -275,12 +277,14 @@ namespace YooAsset
|
|||||||
string location = packageAsset.AssetPath;
|
string location = packageAsset.AssetPath;
|
||||||
|
|
||||||
// 添加原生路径的映射
|
// 添加原生路径的映射
|
||||||
|
#if UNITY_EDITOR || DEBUG
|
||||||
if (manifest.AssetPathMapping1.ContainsKey(location))
|
if (manifest.AssetPathMapping1.ContainsKey(location))
|
||||||
throw new System.Exception($"Location have existed : {location}");
|
throw new System.Exception($"Location have existed : {location}");
|
||||||
else
|
#endif
|
||||||
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||||
|
|
||||||
// 添加无后缀名路径的映射
|
// 添加无后缀名路径的映射
|
||||||
|
// 注意:无后缀名重名属于合法运行时情况(仅警告并跳过),因此该校验必须在发行版也执行。
|
||||||
if (manifest.SupportExtensionless)
|
if (manifest.SupportExtensionless)
|
||||||
{
|
{
|
||||||
string locationWithoutExtension = Path.ChangeExtension(location, null);
|
string locationWithoutExtension = Path.ChangeExtension(location, null);
|
||||||
@@ -297,9 +301,10 @@ namespace YooAsset
|
|||||||
// 填充AssetPathMapping2
|
// 填充AssetPathMapping2
|
||||||
if (manifest.IncludeAssetGUID)
|
if (manifest.IncludeAssetGUID)
|
||||||
{
|
{
|
||||||
|
#if UNITY_EDITOR || DEBUG
|
||||||
if (manifest.AssetPathMapping2.ContainsKey(packageAsset.AssetGUID))
|
if (manifest.AssetPathMapping2.ContainsKey(packageAsset.AssetGUID))
|
||||||
throw new System.Exception($"AssetGUID have existed : {packageAsset.AssetGUID}");
|
throw new System.Exception($"AssetGUID have existed : {packageAsset.AssetGUID}");
|
||||||
else
|
#endif
|
||||||
manifest.AssetPathMapping2.Add(packageAsset.AssetGUID, packageAsset.AssetPath);
|
manifest.AssetPathMapping2.Add(packageAsset.AssetGUID, packageAsset.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,9 +314,10 @@ namespace YooAsset
|
|||||||
string location = packageAsset.Address;
|
string location = packageAsset.Address;
|
||||||
if (string.IsNullOrEmpty(location) == false)
|
if (string.IsNullOrEmpty(location) == false)
|
||||||
{
|
{
|
||||||
|
#if UNITY_EDITOR || DEBUG
|
||||||
if (manifest.AssetPathMapping1.ContainsKey(location))
|
if (manifest.AssetPathMapping1.ContainsKey(location))
|
||||||
throw new System.Exception($"Location have existed : {location}");
|
throw new System.Exception($"Location have existed : {location}");
|
||||||
else
|
#endif
|
||||||
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user