yyl
2026-04-24 97de31e9a015cf139f5293a22e1575a43dfb6733
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("同步资源加载接口已禁用,请使用异步API");
            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)