mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
refactor: rename LoadRawFile API to LoadBundleFile with BundleFileHandle
This commit is contained in:
@@ -94,27 +94,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region RawFileHandle -- GetRawFileData / GetRawFileText
|
#region BundleFileHandle -- GetRawFileData / GetRawFileText
|
||||||
public sealed partial class RawFileHandle
|
public sealed partial class BundleFileHandle
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// v2.3: rawFileHandle.GetRawFileData()
|
/// v2.3: rawFileHandle.GetRawFileData()
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Read file manually via GetRawFilePath().")]
|
[Obsolete("Read file manually via GetBundleFilePath().")]
|
||||||
public byte[] GetRawFileData()
|
public byte[] GetRawFileData()
|
||||||
{
|
{
|
||||||
if (CheckValidWithWarning() == false) return null;
|
if (CheckValidWithWarning() == false) return null;
|
||||||
return System.IO.File.ReadAllBytes(GetRawFilePath());
|
return System.IO.File.ReadAllBytes(GetBundleFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// v2.3: rawFileHandle.GetRawFileText()
|
/// v2.3: rawFileHandle.GetRawFileText()
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Obsolete("Read file manually via GetRawFilePath().")]
|
[Obsolete("Read file manually via GetBundleFilePath().")]
|
||||||
public string GetRawFileText()
|
public string GetRawFileText()
|
||||||
{
|
{
|
||||||
if (CheckValidWithWarning() == false) return null;
|
if (CheckValidWithWarning() == false) return null;
|
||||||
return System.IO.File.ReadAllText(GetRawFilePath());
|
return System.IO.File.ReadAllText(GetBundleFilePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原生文件句柄,用于访问未经 Unity 处理的原始文件。
|
/// 资源包文件句柄,用于持有已加载的资源包引用。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class RawFileHandle : HandleBase
|
public sealed partial class BundleFileHandle : HandleBase
|
||||||
{
|
{
|
||||||
private System.Action<RawFileHandle> _callback;
|
private System.Action<BundleFileHandle> _callback;
|
||||||
|
|
||||||
internal RawFileHandle(ProviderBase provider) : base(provider)
|
internal BundleFileHandle(ProviderBase provider) : base(provider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal override void InvokeCallback()
|
internal override void InvokeCallback()
|
||||||
@@ -19,12 +19,12 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当加载完成时触发
|
/// 当加载完成时触发
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event System.Action<RawFileHandle> Completed
|
public event System.Action<BundleFileHandle> Completed
|
||||||
{
|
{
|
||||||
add
|
add
|
||||||
{
|
{
|
||||||
if (CheckValidWithWarning() == false)
|
if (CheckValidWithWarning() == false)
|
||||||
throw new YooHandleInvalidException($"{nameof(RawFileHandle)} is invalid. It may have been released or the provider was destroyed.");
|
throw new YooHandleInvalidException($"{nameof(BundleFileHandle)} is invalid. It may have been released or the provider was destroyed.");
|
||||||
if (Provider.IsDone)
|
if (Provider.IsDone)
|
||||||
value.Invoke(this);
|
value.Invoke(this);
|
||||||
else
|
else
|
||||||
@@ -33,7 +33,7 @@ namespace YooAsset
|
|||||||
remove
|
remove
|
||||||
{
|
{
|
||||||
if (CheckValidWithWarning() == false)
|
if (CheckValidWithWarning() == false)
|
||||||
throw new YooHandleInvalidException($"{nameof(RawFileHandle)} is invalid. It may have been released or the provider was destroyed.");
|
throw new YooHandleInvalidException($"{nameof(BundleFileHandle)} is invalid. It may have been released or the provider was destroyed.");
|
||||||
_callback -= value;
|
_callback -= value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,10 +49,10 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取原生文件的路径
|
/// 获取资源包文件的路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>原生文件的磁盘路径</returns>
|
/// <returns>资源包文件的磁盘路径</returns>
|
||||||
public string GetRawFilePath()
|
public string GetBundleFilePath()
|
||||||
{
|
{
|
||||||
if (CheckValidWithWarning() == false)
|
if (CheckValidWithWarning() == false)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
@@ -14,7 +14,7 @@ namespace YooAsset
|
|||||||
{ typeof(SceneHandle), op => new SceneHandle(op) },
|
{ typeof(SceneHandle), op => new SceneHandle(op) },
|
||||||
{ typeof(SubAssetsHandle), op => new SubAssetsHandle(op) },
|
{ typeof(SubAssetsHandle), op => new SubAssetsHandle(op) },
|
||||||
{ typeof(AllAssetsHandle), op => new AllAssetsHandle(op) },
|
{ typeof(AllAssetsHandle), op => new AllAssetsHandle(op) },
|
||||||
{ typeof(RawFileHandle), op => new RawFileHandle(op) }
|
{ typeof(BundleFileHandle), op => new BundleFileHandle(op) }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包文件提供者,负责加载资源包文件。
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class BundleFileProvider : ProviderBase
|
||||||
|
{
|
||||||
|
public BundleFileProvider(ResourceManager manager, string providerKey, AssetInfo assetInfo) : base(manager, providerKey, assetInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
protected override void InternalProcessBundleHandle()
|
||||||
|
{
|
||||||
|
SetSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 原生文件提供者,负责加载原始文件资源。
|
|
||||||
/// </summary>
|
|
||||||
internal sealed class RawFileProvider : ProviderBase
|
|
||||||
{
|
|
||||||
public RawFileProvider(ResourceManager manager, string providerKey, AssetInfo assetInfo) : base(manager, providerKey, assetInfo)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
protected override void InternalProcessBundleHandle()
|
|
||||||
{
|
|
||||||
SetSuccess();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -305,12 +305,12 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载原生文件
|
/// 加载资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
/// <param name="priority">加载优先级</param>
|
/// <param name="priority">加载优先级</param>
|
||||||
/// <returns>原生文件句柄</returns>
|
/// <returns>资源包文件句柄</returns>
|
||||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority)
|
public BundleFileHandle LoadBundleFileAsync(AssetInfo assetInfo, uint priority)
|
||||||
{
|
{
|
||||||
if (IsLoadingLocked)
|
if (IsLoadingLocked)
|
||||||
{
|
{
|
||||||
@@ -318,29 +318,29 @@ namespace YooAsset
|
|||||||
YooLogger.LogError(error);
|
YooLogger.LogError(error);
|
||||||
ErrorProvider errorProvider = new ErrorProvider(this, assetInfo);
|
ErrorProvider errorProvider = new ErrorProvider(this, assetInfo);
|
||||||
errorProvider.SetCompletedWithError(error);
|
errorProvider.SetCompletedWithError(error);
|
||||||
return errorProvider.CreateHandle<RawFileHandle>();
|
return errorProvider.CreateHandle<BundleFileHandle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assetInfo.IsValid == false)
|
if (assetInfo.IsValid == false)
|
||||||
{
|
{
|
||||||
YooLogger.LogError($"Failed to load raw file. Error: {assetInfo.Error}");
|
YooLogger.LogError($"Failed to load bundle file. Error: {assetInfo.Error}");
|
||||||
ErrorProvider errorProvider = new ErrorProvider(this, assetInfo);
|
ErrorProvider errorProvider = new ErrorProvider(this, assetInfo);
|
||||||
errorProvider.SetCompletedWithError(assetInfo.Error);
|
errorProvider.SetCompletedWithError(assetInfo.Error);
|
||||||
return errorProvider.CreateHandle<RawFileHandle>();
|
return errorProvider.CreateHandle<BundleFileHandle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
string providerKey = nameof(LoadRawFileAsync) + assetInfo.AssetKey;
|
string providerKey = nameof(LoadBundleFileAsync) + assetInfo.AssetKey;
|
||||||
ProviderBase provider = GetAssetProvider(providerKey);
|
ProviderBase provider = GetAssetProvider(providerKey);
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
{
|
{
|
||||||
provider = new RawFileProvider(this, providerKey, assetInfo);
|
provider = new BundleFileProvider(this, providerKey, assetInfo);
|
||||||
provider.InitProviderDebugInfo();
|
provider.InitProviderDebugInfo();
|
||||||
_providerDict.Add(providerKey, provider);
|
_providerDict.Add(providerKey, provider);
|
||||||
AsyncOperationSystem.StartOperation(PackageName, provider);
|
AsyncOperationSystem.StartOperation(PackageName, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
provider.Priority = priority;
|
provider.Priority = priority;
|
||||||
return provider.CreateHandle<RawFileHandle>();
|
return provider.CreateHandle<BundleFileHandle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ namespace YooAsset
|
|||||||
LoadScene,
|
LoadScene,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载原生文件
|
/// 加载资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
LoadRawFile,
|
LoadBundleFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -419,60 +419,60 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 原生文件
|
#region 资源包文件
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步加载原生文件
|
/// 同步加载资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
/// <returns>返回原生文件操作句柄</returns>
|
/// <returns>返回资源包文件操作句柄</returns>
|
||||||
public RawFileHandle LoadRawFileSync(AssetInfo assetInfo)
|
public BundleFileHandle LoadBundleFileSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
return LoadRawFileInternal(assetInfo, true, 0);
|
return LoadBundleFileInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步加载原生文件
|
/// 同步加载资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <returns>返回原生文件操作句柄</returns>
|
/// <returns>返回资源包文件操作句柄</returns>
|
||||||
public RawFileHandle LoadRawFileSync(string location)
|
public BundleFileHandle LoadBundleFileSync(string location)
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
return LoadRawFileInternal(assetInfo, true, 0);
|
return LoadBundleFileInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载原生文件
|
/// 异步加载资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
/// <param name="priority">加载的优先级</param>
|
/// <param name="priority">加载的优先级</param>
|
||||||
/// <returns>返回原生文件操作句柄</returns>
|
/// <returns>返回资源包文件操作句柄</returns>
|
||||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority = 0)
|
public BundleFileHandle LoadBundleFileAsync(AssetInfo assetInfo, uint priority = 0)
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
return LoadRawFileInternal(assetInfo, false, priority);
|
return LoadBundleFileInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载原生文件
|
/// 异步加载资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="priority">加载的优先级</param>
|
/// <param name="priority">加载的优先级</param>
|
||||||
/// <returns>返回原生文件操作句柄</returns>
|
/// <returns>返回资源包文件操作句柄</returns>
|
||||||
public RawFileHandle LoadRawFileAsync(string location, uint priority = 0)
|
public BundleFileHandle LoadBundleFileAsync(string location, uint priority = 0)
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
return LoadRawFileInternal(assetInfo, false, priority);
|
return LoadBundleFileInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private RawFileHandle LoadRawFileInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
private BundleFileHandle LoadBundleFileInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||||
{
|
{
|
||||||
assetInfo.LoadMethod = ELoadMethod.LoadRawFile;
|
assetInfo.LoadMethod = ELoadMethod.LoadBundleFile;
|
||||||
var handle = _resourceManager.LoadRawFileAsync(assetInfo, priority);
|
var handle = _resourceManager.LoadBundleFileAsync(assetInfo, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
return handle;
|
return handle;
|
||||||
|
|||||||
@@ -6,29 +6,29 @@ using NUnit.Framework;
|
|||||||
using YooAsset;
|
using YooAsset;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 测试原生文件句柄释放与重新加载
|
/// 测试 Bundle 文件句柄释放与重新加载
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// 覆盖 API: LoadRawFileAsync / RawFileHandle.Release / UnloadUnusedAssetsAsync
|
/// 覆盖 API: LoadBundleFileAsync / BundleFileHandle.Release / UnloadUnusedAssetsAsync
|
||||||
/// 测试内容:
|
/// 测试内容:
|
||||||
/// 1. 异步加载原生文件,验证加载成功
|
/// 1. 异步加载 Bundle 文件,验证加载成功
|
||||||
/// 2. 释放 RawFileHandle 引用,等待一帧
|
/// 2. 释放 BundleFileHandle 引用,等待一帧
|
||||||
/// 3. 调用 UnloadUnusedAssetsAsync 清理未使用资源
|
/// 3. 调用 UnloadUnusedAssetsAsync 清理未使用资源
|
||||||
/// 4. 再次加载同一原生文件,验证加载成功且文件路径有效
|
/// 4. 再次加载同一 Bundle 文件,验证加载成功且文件路径有效
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class TestRawFileRelease
|
public class TestBundleFileRelease
|
||||||
{
|
{
|
||||||
public IEnumerator RuntimeTester()
|
public IEnumerator RuntimeTester()
|
||||||
{
|
{
|
||||||
ResourcePackage package = YooAssets.GetPackage(TestConsts.RawBundlePackageName);
|
ResourcePackage package = YooAssets.GetPackage(TestConsts.RawBundlePackageName);
|
||||||
Assert.IsNotNull(package);
|
Assert.IsNotNull(package);
|
||||||
|
|
||||||
var rawFileHandle = package.LoadRawFileAsync("raw_file_e");
|
var bundleFileHandle = package.LoadBundleFileAsync("raw_file_e");
|
||||||
yield return rawFileHandle;
|
yield return bundleFileHandle;
|
||||||
Assert.AreEqual(EOperationStatus.Succeeded, rawFileHandle.Status);
|
Assert.AreEqual(EOperationStatus.Succeeded, bundleFileHandle.Status);
|
||||||
|
|
||||||
// 释放
|
// 释放
|
||||||
rawFileHandle.Release();
|
bundleFileHandle.Release();
|
||||||
yield return new WaitForEndOfFrame();
|
yield return new WaitForEndOfFrame();
|
||||||
|
|
||||||
var unloadOp = package.UnloadUnusedAssetsAsync();
|
var unloadOp = package.UnloadUnusedAssetsAsync();
|
||||||
@@ -36,10 +36,10 @@ public class TestRawFileRelease
|
|||||||
Assert.AreEqual(EOperationStatus.Succeeded, unloadOp.Status);
|
Assert.AreEqual(EOperationStatus.Succeeded, unloadOp.Status);
|
||||||
|
|
||||||
// 再次加载
|
// 再次加载
|
||||||
var reloadHandle = package.LoadRawFileAsync("raw_file_e");
|
var reloadHandle = package.LoadBundleFileAsync("raw_file_e");
|
||||||
yield return reloadHandle;
|
yield return reloadHandle;
|
||||||
Assert.AreEqual(EOperationStatus.Succeeded, reloadHandle.Status);
|
Assert.AreEqual(EOperationStatus.Succeeded, reloadHandle.Status);
|
||||||
Assert.IsTrue(File.Exists(reloadHandle.GetRawFilePath()));
|
Assert.IsTrue(File.Exists(reloadHandle.GetBundleFilePath()));
|
||||||
reloadHandle.Release();
|
reloadHandle.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,17 +7,17 @@ using NUnit.Framework;
|
|||||||
using YooAsset;
|
using YooAsset;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 测试原生文件加载
|
/// 测试 Bundle 文件加载
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// 覆盖 API: LoadRawFileAsync / LoadRawFileSync / LoadAssetAsync(RawFileObject) / LoadAssetSync(RawFileObject)
|
/// 覆盖 API: LoadBundleFileAsync / LoadBundleFileSync / LoadAssetAsync(RawFileObject) / LoadAssetSync(RawFileObject)
|
||||||
/// 测试内容:
|
/// 测试内容:
|
||||||
/// 1. 异步加载原生文件,获取文件路径,验证文件存在且二进制数据非空(raw_file_a)
|
/// 1. 异步加载 Bundle 文件,获取文件路径,验证文件存在且二进制数据非空(raw_file_a)
|
||||||
/// 2. 同步加载原生文件,获取文件路径,验证文件存在且二进制数据非空(raw_file_b)
|
/// 2. 同步加载 Bundle 文件,获取文件路径,验证文件存在且二进制数据非空(raw_file_b)
|
||||||
/// 3. 异步通过 RawFileObject 加载,验证 GetBytes() 和 GetText() 均返回有效数据(raw_file_c)
|
/// 3. 异步通过 RawFileObject 加载,验证 GetBytes() 和 GetText() 均返回有效数据(raw_file_c)
|
||||||
/// 4. 同步通过 RawFileObject 加载,验证 GetBytes() 和 GetText() 均返回有效数据(raw_file_d)
|
/// 4. 同步通过 RawFileObject 加载,验证 GetBytes() 和 GetText() 均返回有效数据(raw_file_d)
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class TestLoadRawFile
|
public class TestLoadBundleFile
|
||||||
{
|
{
|
||||||
public IEnumerator RuntimeTester()
|
public IEnumerator RuntimeTester()
|
||||||
{
|
{
|
||||||
@@ -26,33 +26,33 @@ public class TestLoadRawFile
|
|||||||
|
|
||||||
// 测试异步加载
|
// 测试异步加载
|
||||||
{
|
{
|
||||||
var rawFileHandle = package.LoadRawFileAsync("raw_file_a");
|
var bundleFileHandle = package.LoadBundleFileAsync("raw_file_a");
|
||||||
yield return rawFileHandle;
|
yield return bundleFileHandle;
|
||||||
Assert.AreEqual(EOperationStatus.Succeeded, rawFileHandle.Status);
|
Assert.AreEqual(EOperationStatus.Succeeded, bundleFileHandle.Status);
|
||||||
|
|
||||||
var filePath = rawFileHandle.GetRawFilePath();
|
var filePath = bundleFileHandle.GetBundleFilePath();
|
||||||
Assert.IsNotNull(filePath);
|
Assert.IsNotNull(filePath);
|
||||||
Assert.IsTrue(File.Exists(filePath));
|
Assert.IsTrue(File.Exists(filePath));
|
||||||
|
|
||||||
byte[] fileBytes = File.ReadAllBytes(filePath);
|
byte[] fileBytes = File.ReadAllBytes(filePath);
|
||||||
Assert.IsNotNull(fileBytes);
|
Assert.IsNotNull(fileBytes);
|
||||||
Assert.Greater(fileBytes.Length, 0);
|
Assert.Greater(fileBytes.Length, 0);
|
||||||
rawFileHandle.Release();
|
bundleFileHandle.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试同步加载
|
// 测试同步加载
|
||||||
{
|
{
|
||||||
var rawFileHandle = package.LoadRawFileSync("raw_file_b");
|
var bundleFileHandle = package.LoadBundleFileSync("raw_file_b");
|
||||||
Assert.AreEqual(EOperationStatus.Succeeded, rawFileHandle.Status);
|
Assert.AreEqual(EOperationStatus.Succeeded, bundleFileHandle.Status);
|
||||||
|
|
||||||
var filePath = rawFileHandle.GetRawFilePath();
|
var filePath = bundleFileHandle.GetBundleFilePath();
|
||||||
Assert.IsNotNull(filePath);
|
Assert.IsNotNull(filePath);
|
||||||
Assert.IsTrue(File.Exists(filePath));
|
Assert.IsTrue(File.Exists(filePath));
|
||||||
|
|
||||||
byte[] fileBytes = File.ReadAllBytes(filePath);
|
byte[] fileBytes = File.ReadAllBytes(filePath);
|
||||||
Assert.IsNotNull(fileBytes);
|
Assert.IsNotNull(fileBytes);
|
||||||
Assert.Greater(fileBytes.Length, 0);
|
Assert.Greater(fileBytes.Length, 0);
|
||||||
rawFileHandle.Release();
|
bundleFileHandle.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试异步加载:通过 RawFileObject 获取二进制数据和文本数据
|
// 测试异步加载:通过 RawFileObject 获取二进制数据和文本数据
|
||||||
@@ -241,9 +241,9 @@ public class T1_TestEditorFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
}
|
}
|
||||||
|
|
||||||
[UnityTest]
|
[UnityTest]
|
||||||
public IEnumerator B10_TestLoadRawFile()
|
public IEnumerator B10_TestLoadBundleFile()
|
||||||
{
|
{
|
||||||
var tester = new TestLoadRawFile();
|
var tester = new TestLoadBundleFile();
|
||||||
yield return tester.RuntimeTester();
|
yield return tester.RuntimeTester();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,9 +304,9 @@ public class T1_TestEditorFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
}
|
}
|
||||||
|
|
||||||
[UnityTest]
|
[UnityTest]
|
||||||
public IEnumerator C07_TestRawFileRelease()
|
public IEnumerator C07_TestBundleFileRelease()
|
||||||
{
|
{
|
||||||
var tester = new TestRawFileRelease();
|
var tester = new TestBundleFileRelease();
|
||||||
yield return tester.RuntimeTester();
|
yield return tester.RuntimeTester();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -241,9 +241,9 @@ public class T2_TestBuiltinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
}
|
}
|
||||||
|
|
||||||
[UnityTest]
|
[UnityTest]
|
||||||
public IEnumerator B10_TestLoadRawFile()
|
public IEnumerator B10_TestLoadBundleFile()
|
||||||
{
|
{
|
||||||
var tester = new TestLoadRawFile();
|
var tester = new TestLoadBundleFile();
|
||||||
yield return tester.RuntimeTester();
|
yield return tester.RuntimeTester();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,9 +333,9 @@ public class T2_TestBuiltinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
}
|
}
|
||||||
|
|
||||||
[UnityTest]
|
[UnityTest]
|
||||||
public IEnumerator D07_TestRawFileRelease()
|
public IEnumerator D07_TestBundleFileRelease()
|
||||||
{
|
{
|
||||||
var tester = new TestRawFileRelease();
|
var tester = new TestBundleFileRelease();
|
||||||
yield return tester.RuntimeTester();
|
yield return tester.RuntimeTester();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ namespace Cysharp.Threading.Tasks
|
|||||||
case SubAssetsHandle sub_asset_handle:
|
case SubAssetsHandle sub_asset_handle:
|
||||||
sub_asset_handle.Completed += result.SubContinuation;
|
sub_asset_handle.Completed += result.SubContinuation;
|
||||||
break;
|
break;
|
||||||
case RawFileHandle raw_file_handle:
|
case BundleFileHandle bundle_file_handle:
|
||||||
raw_file_handle.Completed += result.RawFileContinuation;
|
bundle_file_handle.Completed += result.BundleFileContinuation;
|
||||||
break;
|
break;
|
||||||
case AllAssetsHandle all_assets_handle:
|
case AllAssetsHandle all_assets_handle:
|
||||||
all_assets_handle.Completed += result.AllAssetsContinuation;
|
all_assets_handle.Completed += result.AllAssetsContinuation;
|
||||||
@@ -120,8 +120,8 @@ namespace Cysharp.Threading.Tasks
|
|||||||
case SubAssetsHandle sub_asset_handle:
|
case SubAssetsHandle sub_asset_handle:
|
||||||
sub_asset_handle.Completed += result.completedCallback;
|
sub_asset_handle.Completed += result.completedCallback;
|
||||||
break;
|
break;
|
||||||
case RawFileHandle raw_file_handle:
|
case BundleFileHandle bundle_file_handle:
|
||||||
raw_file_handle.Completed += result.completedCallback;
|
bundle_file_handle.Completed += result.completedCallback;
|
||||||
break;
|
break;
|
||||||
case AllAssetsHandle all_assets_handle:
|
case AllAssetsHandle all_assets_handle:
|
||||||
all_assets_handle.Completed += result.completedCallback;
|
all_assets_handle.Completed += result.completedCallback;
|
||||||
@@ -137,7 +137,7 @@ namespace Cysharp.Threading.Tasks
|
|||||||
void AssetContinuation(AssetHandle _) => HandleCompleted(null);
|
void AssetContinuation(AssetHandle _) => HandleCompleted(null);
|
||||||
void SceneContinuation(SceneHandle _) => HandleCompleted(null);
|
void SceneContinuation(SceneHandle _) => HandleCompleted(null);
|
||||||
void SubContinuation(SubAssetsHandle _) => HandleCompleted(null);
|
void SubContinuation(SubAssetsHandle _) => HandleCompleted(null);
|
||||||
void RawFileContinuation(RawFileHandle _) => HandleCompleted(null);
|
void BundleFileContinuation(BundleFileHandle _) => HandleCompleted(null);
|
||||||
void AllAssetsContinuation(AllAssetsHandle _) => HandleCompleted(null);
|
void AllAssetsContinuation(AllAssetsHandle _) => HandleCompleted(null);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -174,8 +174,8 @@ namespace Cysharp.Threading.Tasks
|
|||||||
case SubAssetsHandle sub_asset_handle:
|
case SubAssetsHandle sub_asset_handle:
|
||||||
sub_asset_handle.Completed -= SubContinuation;
|
sub_asset_handle.Completed -= SubContinuation;
|
||||||
break;
|
break;
|
||||||
case RawFileHandle raw_file_handle:
|
case BundleFileHandle bundle_file_handle:
|
||||||
raw_file_handle.Completed -= RawFileContinuation;
|
bundle_file_handle.Completed -= BundleFileContinuation;
|
||||||
break;
|
break;
|
||||||
case AllAssetsHandle all_assets_handle:
|
case AllAssetsHandle all_assets_handle:
|
||||||
all_assets_handle.Completed -= AllAssetsContinuation;
|
all_assets_handle.Completed -= AllAssetsContinuation;
|
||||||
@@ -193,8 +193,8 @@ namespace Cysharp.Threading.Tasks
|
|||||||
case SubAssetsHandle sub_asset_handle:
|
case SubAssetsHandle sub_asset_handle:
|
||||||
sub_asset_handle.Completed -= completedCallback;
|
sub_asset_handle.Completed -= completedCallback;
|
||||||
break;
|
break;
|
||||||
case RawFileHandle raw_file_handle:
|
case BundleFileHandle bundle_file_handle:
|
||||||
raw_file_handle.Completed -= completedCallback;
|
bundle_file_handle.Completed -= completedCallback;
|
||||||
break;
|
break;
|
||||||
case AllAssetsHandle all_assets_handle:
|
case AllAssetsHandle all_assets_handle:
|
||||||
all_assets_handle.Completed -= completedCallback;
|
all_assets_handle.Completed -= completedCallback;
|
||||||
|
|||||||
Reference in New Issue
Block a user