update resource package

pull/189/head
hevinci 2023-09-27 12:04:11 +08:00
parent bae55ca511
commit 4234885f94
3 changed files with 38 additions and 12 deletions

View File

@ -93,17 +93,6 @@ namespace YooAsset
AssetType = assetType;
Error = string.Empty;
}
internal AssetInfo(string packageName, PackageAsset packageAsset)
{
if (packageAsset == null)
throw new System.Exception("Should never get here !");
_providerGUID = string.Empty;
_packageAsset = packageAsset;
PackageName = packageName;
AssetType = null;
Error = string.Empty;
}
internal AssetInfo(string packageName, string error)
{
_providerGUID = string.Empty;

View File

@ -207,7 +207,7 @@ namespace YooAsset
{
if (packageAsset.HasTag(tags))
{
AssetInfo assetInfo = new AssetInfo(PackageName, packageAsset);
AssetInfo assetInfo = new AssetInfo(PackageName, packageAsset, null);
result.Add(assetInfo);
}
}

View File

@ -447,6 +447,17 @@ namespace YooAsset
return ConvertLocationToAssetInfo(location, null);
}
/// <summary>
/// 获取资源信息
/// </summary>
/// <param name="location">资源的定位地址</param>
/// <param name="type">资源类型</param>
public AssetInfo GetAssetInfo(string location, System.Type type)
{
DebugCheckInitialize();
return ConvertLocationToAssetInfo(location, type);
}
/// <summary>
/// 获取资源信息
/// </summary>
@ -457,6 +468,17 @@ namespace YooAsset
return ConvertAssetGUIDToAssetInfo(assetGUID, null);
}
/// <summary>
/// 获取资源信息
/// </summary>
/// <param name="assetGUID">资源GUID</param>
/// <param name="type">资源类型</param>
public AssetInfo GetAssetInfoByGUID(string assetGUID, System.Type type)
{
DebugCheckInitialize();
return ConvertAssetGUIDToAssetInfo(assetGUID, type);
}
/// <summary>
/// 检查资源定位地址是否有效
/// </summary>
@ -674,6 +696,7 @@ namespace YooAsset
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
{
DebugCheckAssetLoadMethod(nameof(LoadAssetAsync));
DebugCheckAssetLoadType(assetInfo.AssetType);
var handle = _resourceMgr.LoadAssetAsync(assetInfo);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
@ -779,6 +802,7 @@ namespace YooAsset
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
{
DebugCheckAssetLoadMethod(nameof(LoadSubAssetsAsync));
DebugCheckAssetLoadType(assetInfo.AssetType);
var handle = _resourceMgr.LoadSubAssetsAsync(assetInfo);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
@ -884,6 +908,7 @@ namespace YooAsset
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
{
DebugCheckAssetLoadMethod(nameof(LoadAllAssetsAsync));
DebugCheckAssetLoadType(assetInfo.AssetType);
var handle = _resourceMgr.LoadAllAssetsAsync(assetInfo);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
@ -1109,6 +1134,18 @@ namespace YooAsset
throw new Exception($"Cannot load raw file using {method} method !");
}
}
[Conditional("DEBUG")]
private void DebugCheckAssetLoadType(System.Type type)
{
if (type == null)
return;
if (typeof(UnityEngine.Object).IsAssignableFrom(type) == false)
{
throw new Exception($"Load asset type is invalid : {type.FullName} !");
}
}
#endregion
#region 调试信息