mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-23 01:00:16 +00:00
Support addressable location
支持可寻址资源定位
This commit is contained in:
@@ -12,6 +12,11 @@ namespace YooAsset
|
||||
[Serializable]
|
||||
internal class PatchManifest
|
||||
{
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable;
|
||||
|
||||
/// <summary>
|
||||
/// 资源版本号
|
||||
/// </summary>
|
||||
@@ -45,6 +50,12 @@ namespace YooAsset
|
||||
[NonSerialized]
|
||||
public readonly Dictionary<string, PatchAsset> Assets = new Dictionary<string, PatchAsset>();
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址映射集合
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
public readonly Dictionary<string, string> AddressDic = new Dictionary<string, string>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置资源标签列表
|
||||
@@ -108,6 +119,22 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址转换为资源路径
|
||||
/// </summary>
|
||||
public string ConvertAddress(string address)
|
||||
{
|
||||
if (AddressDic.TryGetValue(address, out string assetPath))
|
||||
{
|
||||
return assetPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found address in patch manifest : {address}");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 序列化
|
||||
@@ -155,6 +182,19 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
// Address
|
||||
if (patchManifest.EnableAddressable)
|
||||
{
|
||||
foreach (var patchAsset in patchManifest.AssetList)
|
||||
{
|
||||
string address = patchAsset.Address;
|
||||
if (patchManifest.AddressDic.ContainsKey(address))
|
||||
throw new Exception($"Address have existed : {address}");
|
||||
else
|
||||
patchManifest.AddressDic.Add(address, patchAsset.AssetPath);
|
||||
}
|
||||
}
|
||||
|
||||
return patchManifest;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user