mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-28 19:48:47 +00:00
update test sample
This commit is contained in:
@@ -36,7 +36,7 @@ public class T3_TestCacheFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
throw new Exception($"Not found package root : {packageRoot}");
|
throw new Exception($"Not found package root : {packageRoot}");
|
||||||
|
|
||||||
string testServerDirectory = "C://xampp/htdocs/CDN/Android/Test";
|
string testServerDirectory = "C://xampp/htdocs/CDN/Android/Test";
|
||||||
|
CopyDirectory(packageRoot, testServerDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化资源包 ASSET_BUNDLE
|
// 初始化资源包 ASSET_BUNDLE
|
||||||
@@ -114,4 +114,32 @@ public class T3_TestCacheFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
var tester = new TestBundleDownloader();
|
var tester = new TestBundleDownloader();
|
||||||
yield return tester.RuntimeTester();
|
yield return tester.RuntimeTester();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CopyDirectory(string sourceDir, string targetDir)
|
||||||
|
{
|
||||||
|
// 检查源目录是否存在
|
||||||
|
if (!Directory.Exists(sourceDir))
|
||||||
|
{
|
||||||
|
throw new DirectoryNotFoundException($"源目录不存在: {sourceDir}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建目标目录(如果不存在)
|
||||||
|
Directory.CreateDirectory(targetDir);
|
||||||
|
|
||||||
|
// 拷贝所有文件
|
||||||
|
foreach (string file in Directory.GetFiles(sourceDir))
|
||||||
|
{
|
||||||
|
string fileName = Path.GetFileName(file);
|
||||||
|
string destFile = Path.Combine(targetDir, fileName);
|
||||||
|
File.Copy(file, destFile, true); // true 表示覆盖已存在文件
|
||||||
|
}
|
||||||
|
|
||||||
|
// 递归拷贝子目录
|
||||||
|
foreach (string subDir in Directory.GetDirectories(sourceDir))
|
||||||
|
{
|
||||||
|
string dirName = Path.GetFileName(subDir);
|
||||||
|
string newTargetDir = Path.Combine(targetDir, dirName);
|
||||||
|
CopyDirectory(subDir, newTargetDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -34,10 +34,18 @@ public class TestBundlePlaying
|
|||||||
|
|
||||||
// 测试同步加载
|
// 测试同步加载
|
||||||
{
|
{
|
||||||
|
// 验证失败结果
|
||||||
|
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = true;
|
||||||
var assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
|
var assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
|
||||||
yield return assetsHandle;
|
yield return assetsHandle;
|
||||||
Assert.AreEqual(EOperationStatus.Failed, assetsHandle.Status);
|
Assert.AreEqual(EOperationStatus.Failed, assetsHandle.Status);
|
||||||
|
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = false;
|
||||||
|
|
||||||
|
// 清理加载器
|
||||||
|
assetsHandle.Release();
|
||||||
|
package.UnloadUnusedAssetsAsync();
|
||||||
|
|
||||||
|
// 验证成功结果
|
||||||
yield return new WaitForSeconds(1f);
|
yield return new WaitForSeconds(1f);
|
||||||
assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
|
assetsHandle = package.LoadAssetSync<GameObject>("panel_b");
|
||||||
yield return assetsHandle;
|
yield return assetsHandle;
|
||||||
|
|||||||
Reference in New Issue
Block a user