Update asset system

pull/62/head
hevinci 2022-12-03 19:13:11 +08:00
parent 4abec5a389
commit 6038e7acd6
4 changed files with 67 additions and 53 deletions

View File

@ -1,9 +1,10 @@
using UnityEngine;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace YooAsset
{
public sealed class AssetOperationHandle : OperationHandleBase
public sealed class AssetOperationHandle : OperationHandleBase, IDisposable
{
private System.Action<AssetOperationHandle> _callback;
@ -37,6 +38,33 @@ namespace YooAsset
}
}
/// <summary>
/// 等待异步执行完毕
/// </summary>
public void WaitForAsyncComplete()
{
if (IsValidWithWarning == false)
return;
Provider.WaitForAsyncComplete();
}
/// <summary>
/// 释放资源句柄
/// </summary>
public void Release()
{
this.ReleaseInternal();
}
/// <summary>
/// 释放资源句柄
/// </summary>
public void Dispose()
{
this.ReleaseInternal();
}
/// <summary>
/// 资源对象
/// </summary>
@ -61,25 +89,6 @@ namespace YooAsset
return Provider.AssetObject as TAsset;
}
/// <summary>
/// 等待异步执行完毕
/// </summary>
public void WaitForAsyncComplete()
{
if (IsValidWithWarning == false)
return;
Provider.WaitForAsyncComplete();
}
/// <summary>
/// 释放资源句柄
/// </summary>
public void Release()
{
this.ReleaseInternal();
}
/// <summary>
/// 同步初始化游戏对象
/// </summary>

View File

@ -3,20 +3,8 @@ using System.Collections;
namespace YooAsset
{
public abstract class OperationHandleBase : IEnumerator, IDisposable
public abstract class OperationHandleBase : IEnumerator
{
private bool _isDisposed;
public void Dispose()
{
if (_isDisposed)
{
return;
}
_isDisposed = true;
ReleaseInternal();
}
private readonly AssetInfo _assetInfo;
internal ProviderBase Provider { private set; get; }
@ -27,7 +15,6 @@ namespace YooAsset
}
internal abstract void InvokeCallback();
/// <summary>
/// 获取资源信息
/// </summary>

View File

@ -1,9 +1,10 @@
using System.IO;
using System;
using System.IO;
using System.Text;
namespace YooAsset
{
public class RawFileOperationHandle : OperationHandleBase
public class RawFileOperationHandle : OperationHandleBase, IDisposable
{
private System.Action<RawFileOperationHandle> _callback;
@ -54,7 +55,15 @@ namespace YooAsset
{
this.ReleaseInternal();
}
/// <summary>
/// 释放资源句柄
/// </summary>
public void Dispose()
{
this.ReleaseInternal();
}
/// <summary>
/// 获取原生文件的二进制数据

View File

@ -1,8 +1,9 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace YooAsset
{
public sealed class SubAssetsOperationHandle : OperationHandleBase
public sealed class SubAssetsOperationHandle : OperationHandleBase, IDisposable
{
private System.Action<SubAssetsOperationHandle> _callback;
@ -36,19 +37,6 @@ namespace YooAsset
}
}
/// <summary>
/// 子资源对象集合
/// </summary>
public UnityEngine.Object[] AllAssetObjects
{
get
{
if (IsValidWithWarning == false)
return null;
return Provider.AllAssetObjects;
}
}
/// <summary>
/// 等待异步执行完毕
/// </summary>
@ -67,6 +55,27 @@ namespace YooAsset
this.ReleaseInternal();
}
/// <summary>
/// 释放资源句柄
/// </summary>
public void Dispose()
{
this.ReleaseInternal();
}
/// <summary>
/// 子资源对象集合
/// </summary>
public UnityEngine.Object[] AllAssetObjects
{
get
{
if (IsValidWithWarning == false)
return null;
return Provider.AllAssetObjects;
}
}
/// <summary>
/// 获取子资源对象