| | |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | case EPlayMode.HostPlayMode: |
| | | { |
| | | bool hasBuildin = YooAssetInitializer.HasBuildinPackage(packageName); |
| | | return new HostPlayModeParameters |
| | | { |
| | | BuildinFileSystemParameters = FileSystemParameters |
| | | .CreateDefaultBuildinFileSystemParameters(), |
| | | BuildinFileSystemParameters = hasBuildin |
| | | ? FileSystemParameters.CreateDefaultBuildinFileSystemParameters() |
| | | : null, |
| | | CacheFileSystemParameters = FileSystemParameters |
| | | .CreateDefaultCacheFileSystemParameters(remoteServices) |
| | | }; |
| | |
| | | } |
| | | |
| | | /// <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 /> |
| | |
| | | // 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) |