update yooasset2.0

This commit is contained in:
hevinci
2023-09-20 16:10:57 +08:00
parent 6687d75090
commit 6fb5a4b946
5 changed files with 10 additions and 38 deletions
@@ -5,28 +5,10 @@ using YooAsset;
public static class AssetOperationHandleExtension
{
/*
/// <summary>
/// 获取资源对象
/// </summary>
/// <typeparam name="TAsset"></typeparam>
/// <param name="asset"></param>
public static AssetOperationHandle GetAssetObject<TAsset>(this AssetOperationHandle thisHandle, out TAsset asset) where TAsset : UnityEngine.Object
{
if (thisHandle.Status != EOperationStatus.Succeed)
{
var assetInfo = thisHandle.GetAssetInfo();
Debug.LogWarning($"The {assetInfo.AssetPath}[{assetInfo.AssetType}] is not success. Error[{thisHandle.LastError}]");
}
asset = thisHandle.AssetObject as TAsset;
return thisHandle;
}
*/
/// <summary>
/// 等待异步执行完毕
/// </summary>
public static AssetOperationHandle WaitForAsyncOperationComplete(this AssetOperationHandle thisHandle)
public static AssetHandle WaitForAsyncOperationComplete(this AssetHandle thisHandle)
{
thisHandle.WaitForAsyncComplete();
return thisHandle;
@@ -45,7 +45,7 @@ public class GameObjectAssetReference : MonoBehaviour
[HideInInspector]
public string AssetGUID = "";
private AssetOperationHandle _handle;
private AssetHandle _handle;
public void Start()
{
@@ -63,7 +63,7 @@ public class GameObjectAssetReference : MonoBehaviour
}
}
private void Handle_Completed(AssetOperationHandle handle)
private void Handle_Completed(AssetHandle handle)
{
if (handle.Status == EOperationStatus.Succeed)
{
@@ -16,7 +16,7 @@ public class LoadAssetsByTagOperation<TObject> : GameAsyncOperation where TObjec
private readonly string _tag;
private ESteps _steps = ESteps.None;
private List<AssetOperationHandle> _handles;
private List<AssetHandle> _handles;
/// <summary>
/// 资源对象集合
@@ -40,7 +40,7 @@ public class LoadAssetsByTagOperation<TObject> : GameAsyncOperation where TObjec
if (_steps == ESteps.LoadAssets)
{
AssetInfo[] assetInfos = YooAssets.GetAssetInfos(_tag);
_handles = new List<AssetOperationHandle>(assetInfos.Length);
_handles = new List<AssetHandle>(assetInfos.Length);
foreach (var assetInfo in assetInfos)
{
var handle = YooAssets.LoadAssetAsync(assetInfo);