mirror of https://github.com/tuyoogame/YooAsset
parent
8260653eae
commit
029b850d6b
|
@ -1,4 +1,5 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public sealed class SubAssetsOperationHandle : OperationHandleBase
|
public sealed class SubAssetsOperationHandle : OperationHandleBase
|
||||||
|
@ -77,32 +78,33 @@ namespace YooAsset
|
||||||
if (IsValid == false)
|
if (IsValid == false)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
foreach (var asset in Provider.AllAssetObjects)
|
foreach (var assetObject in Provider.AllAssetObjects)
|
||||||
{
|
{
|
||||||
if (asset.name == assetName)
|
if (assetObject.name == assetName)
|
||||||
return asset as TObject;
|
return assetObject as TObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Warning($"Not found sub asset object : {assetName}");
|
YooLogger.Warning($"Not found sub asset object : {assetName}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取图集下所有的精灵对象集合
|
/// 获取所有的子资源对象集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">子资源对象类型</typeparam>
|
/// <typeparam name="TObject">子资源对象类型</typeparam>
|
||||||
public TObject[] GetSubAssetObjects<TObject>() where TObject : UnityEngine.Object
|
public TObject[] GetSubAssetObjects<TObject>() where TObject : UnityEngine.Object
|
||||||
{
|
{
|
||||||
List<TObject> ret = new List<TObject>();
|
|
||||||
if (IsValid == false)
|
if (IsValid == false)
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var e in _provider.AllAssetObjects)
|
List<TObject> ret = new List<TObject>(Provider.AllAssetObjects.Length);
|
||||||
|
foreach (var assetObject in Provider.AllAssetObjects)
|
||||||
{
|
{
|
||||||
ret.Add(e as TObject);
|
var retObject = assetObject as TObject;
|
||||||
|
if (retObject != null)
|
||||||
|
ret.Add(retObject);
|
||||||
|
else
|
||||||
|
YooLogger.Warning($"The type conversion failed : {assetObject.name}");
|
||||||
}
|
}
|
||||||
return ret.ToArray();
|
return ret.ToArray();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue