mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-26 18:50:10 +00:00
update test sample
This commit is contained in:
@@ -16,28 +16,27 @@ public class TestBundlePlaying
|
||||
ResourcePackage package = YooAssets.GetPackage(TestDefine.AssetBundlePackageName);
|
||||
Assert.IsNotNull(package);
|
||||
|
||||
if (package.IsNeedDownloadFromRemote("panel_a") == false)
|
||||
if (package.IsNeedDownloadFromRemote("prefab_encryptA") == false)
|
||||
{
|
||||
Assert.Fail("Load bundle is already existed !");
|
||||
}
|
||||
if (package.IsNeedDownloadFromRemote("panel_b") == false)
|
||||
if (package.IsNeedDownloadFromRemote("prefab_encryptB") == false)
|
||||
{
|
||||
Assert.Fail("Load bundle is already existed !");
|
||||
}
|
||||
|
||||
// 测试异步加载
|
||||
// 测试异步加载远端资源
|
||||
{
|
||||
var assetsHandle = package.LoadAssetAsync<GameObject>("panel_a");
|
||||
var assetsHandle = package.LoadAssetAsync<GameObject>("prefab_encryptA");
|
||||
yield return assetsHandle;
|
||||
Assert.AreEqual(EOperationStatus.Succeed, assetsHandle.Status);
|
||||
}
|
||||
|
||||
// 测试同步加载
|
||||
// 测试同步加载远端资源
|
||||
{
|
||||
// 验证失败结果
|
||||
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = true;
|
||||
var assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
|
||||
yield return assetsHandle;
|
||||
var assetsHandle = package.LoadAssetSync<GameObject>("prefab_encryptB");
|
||||
Assert.AreEqual(EOperationStatus.Failed, assetsHandle.Status);
|
||||
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = false;
|
||||
|
||||
@@ -46,34 +45,38 @@ public class TestBundlePlaying
|
||||
package.UnloadUnusedAssetsAsync();
|
||||
|
||||
// 验证成功结果
|
||||
// 说明:同步加载也会触发远端下载任务!
|
||||
yield return new WaitForSeconds(1f);
|
||||
assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
|
||||
yield return assetsHandle;
|
||||
assetsHandle = package.LoadAssetSync<GameObject>("prefab_encryptB");
|
||||
Assert.AreEqual(EOperationStatus.Succeed, assetsHandle.Status);
|
||||
}
|
||||
|
||||
// 等待一秒
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
}
|
||||
|
||||
/* 资源代码流程
|
||||
* 远端文件下载(加载器)
|
||||
* 远端文件下载(加载器触发)
|
||||
CacheFileSystem::LoadBundleFile()
|
||||
{
|
||||
_cacheFileSystem.LoadBundleFile(bundle);
|
||||
}
|
||||
CacheFileSystem::LoadAssetBundleOperation()
|
||||
DCFSLoadAssetBundleOperation::InternalUpdate()
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
|
||||
_cacheFileSystem.DownloadFileAsync(_bundle, options);
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
_cacheFileSystem.DownloadFileAsync(_bundle, options);
|
||||
}
|
||||
}
|
||||
CacheFileSystem::DownloadFileAsync()
|
||||
{
|
||||
//RemoteServices返回CDN文件路径
|
||||
string mainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
|
||||
string fallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
||||
options.SetURL(mainURL, fallbackURL);
|
||||
return new DownloadPackageBundleOperation(bundle, options);
|
||||
if (string.IsNullOrEmpty(options.ImportFilePath))
|
||||
{
|
||||
//RemoteServices返回CDN文件路径
|
||||
string mainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
|
||||
string fallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
||||
options.SetURL(mainURL, fallbackURL);
|
||||
var downloader = new DownloadPackageBundleOperation(bundle, options);
|
||||
return downloader;
|
||||
}
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user