From 97de31e9a015cf139f5293a22e1575a43dfb6733 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 24 四月 2026 14:16:02 +0800
Subject: [PATCH] WEBGL ANDROID适配
---
Main/ResModule/YooAssetService.cs | 51 ++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/Main/ResModule/YooAssetService.cs b/Main/ResModule/YooAssetService.cs
index b501d7f..994ee58 100644
--- a/Main/ResModule/YooAssetService.cs
+++ b/Main/ResModule/YooAssetService.cs
@@ -102,7 +102,8 @@
if (initOp.Status != EOperationStatus.Succeed)
{
- Debug.LogWarning($"[YooAssetService] Package '{pkgName}' re-init failed: {initOp.Error}");
+ Debug.LogError($"[YooAssetService] Package '{pkgName}' re-init failed: {initOp.Error}");
+ try { var d = package.DestroyAsync(); await d.ToUniTask(); YooAssets.RemovePackage(pkgName); } catch { }
continue;
}
@@ -122,7 +123,14 @@
if (initOp.Status != EOperationStatus.Succeed)
{
- Debug.LogWarning($"[YooAssetService] Package '{pkgName}' init failed: {initOp.Error}");
+ Debug.LogError($"[YooAssetService] Package '{pkgName}' init failed: {initOp.Error}");
+ try
+ {
+ var dOp = package.DestroyAsync();
+ await dOp.ToUniTask();
+ YooAssets.RemovePackage(pkgName);
+ }
+ catch { }
continue;
}
@@ -238,10 +246,12 @@
}
case EPlayMode.HostPlayMode:
{
+ bool hasBuildin = YooAssetInitializer.HasBuildinPackage(packageName);
return new HostPlayModeParameters
{
- BuildinFileSystemParameters = FileSystemParameters
- .CreateDefaultBuildinFileSystemParameters(),
+ BuildinFileSystemParameters = hasBuildin
+ ? FileSystemParameters.CreateDefaultBuildinFileSystemParameters()
+ : null,
CacheFileSystemParameters = FileSystemParameters
.CreateDefaultCacheFileSystemParameters(remoteServices)
};
@@ -478,12 +488,27 @@
}
/// <summary>
- /// 鍚屾鍔犺浇璧勪骇锛堜粎鍦ㄩ潪 WebGL 骞冲彴杩囨浮鏈熶娇鐢級銆�
+ /// 鍚屾鍔犺浇璧勪骇锛堥潪 WebGL 骞冲彴浣跨敤锛夈��
+ /// WebGL 涓嶆敮鎸佸悓姝ュ姞杞斤紝璇蜂娇鐢� LoadAssetAsync銆�
/// </summary>
- [System.Obsolete("Use LoadAssetAsync instead. Sync loading will be removed in US2.")]
public T LoadAssetSync<T>(string location) where T : UnityEngine.Object
{
- throw new NotSupportedException("鍚屾璧勬簮鍔犺浇鎺ュ彛宸茬鐢紝璇蜂娇鐢ㄥ紓姝PI");
+ ThrowIfNotInitialized();
+
+ if (string.IsNullOrEmpty(location))
+ {
+ Debug.LogError("[YooAssetService] LoadAssetSync: location is null or empty.");
+ return null;
+ }
+
+ var package = FindPackageForAsset(location);
+ var handle = package.LoadAssetSync<T>(location);
+ if (handle.Status != EOperationStatus.Succeed)
+ {
+ Debug.LogError($"[YooAssetService] LoadAssetSync failed for '{location}': {handle.LastError}");
+ return null;
+ }
+ return handle.GetAssetObject<T>();
}
/// <inheritdoc />
@@ -592,6 +617,18 @@
// Scene Loading
// ====================================================================
+ /// <summary>
+ /// 寮�濮嬪姞杞藉満鏅紝杩斿洖 SceneHandle 渚涜皟鐢ㄦ柟鑷鎺у埗杩涘害鍜屾寕璧枫��
+ /// 涓嶄細绛夊緟鍔犺浇瀹屾垚銆�
+ /// </summary>
+ public SceneHandle BeginLoadScene(string location, LoadSceneMode sceneMode = LoadSceneMode.Single,
+ LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 0)
+ {
+ ThrowIfNotInitialized();
+ var package = FindPackageForAsset(location);
+ return package.LoadSceneAsync(location, sceneMode, physicsMode, suspendLoad, priority);
+ }
+
/// <inheritdoc />
public async UniTask<SceneHandle> LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single,
LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 0, CancellationToken ct = default)
--
Gitblit v1.8.0