diff --git a/Assets/YooAsset/Runtime/ResourcePackage/AssetInfo.cs b/Assets/YooAsset/Runtime/ResourcePackage/AssetInfo.cs
index 69a5f6d..d5924b4 100644
--- a/Assets/YooAsset/Runtime/ResourcePackage/AssetInfo.cs
+++ b/Assets/YooAsset/Runtime/ResourcePackage/AssetInfo.cs
@@ -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;
diff --git a/Assets/YooAsset/Runtime/ResourcePackage/PackageManifest.cs b/Assets/YooAsset/Runtime/ResourcePackage/PackageManifest.cs
index 97f89a1..46fc396 100644
--- a/Assets/YooAsset/Runtime/ResourcePackage/PackageManifest.cs
+++ b/Assets/YooAsset/Runtime/ResourcePackage/PackageManifest.cs
@@ -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);
}
}
diff --git a/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs b/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs
index f3f31bc..f35fffe 100644
--- a/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs
+++ b/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs
@@ -447,6 +447,17 @@ namespace YooAsset
return ConvertLocationToAssetInfo(location, null);
}
+ ///
+ /// 获取资源信息
+ ///
+ /// 资源的定位地址
+ /// 资源类型
+ public AssetInfo GetAssetInfo(string location, System.Type type)
+ {
+ DebugCheckInitialize();
+ return ConvertLocationToAssetInfo(location, type);
+ }
+
///
/// 获取资源信息
///
@@ -457,6 +468,17 @@ namespace YooAsset
return ConvertAssetGUIDToAssetInfo(assetGUID, null);
}
+ ///
+ /// 获取资源信息
+ ///
+ /// 资源GUID
+ /// 资源类型
+ public AssetInfo GetAssetInfoByGUID(string assetGUID, System.Type type)
+ {
+ DebugCheckInitialize();
+ return ConvertAssetGUIDToAssetInfo(assetGUID, type);
+ }
+
///
/// 检查资源定位地址是否有效
///
@@ -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 调试信息