yyl
2026-03-04 bc1cb6da854cb2e9144f10ed55330a537ecdca16
Main/ResModule/YooAssetService.cs
@@ -413,6 +413,29 @@
            }, $"LoadAssetAsync<{typeof(T).Name}>('{location}')", ct);
        }
        public void UnloadAsset(string location)
        {
            ThrowIfNotInitialized();
            if (string.IsNullOrEmpty(location))
            {
                Debug.LogError("[YooAssetService] UnloadAsset: location is null or empty.");
                return;
            }
            var package = FindPackageForAsset(location);
            if (null != package)
            {
                YooAsset.AssetInfo assetInfo = package.GetAssetInfo(location);
                if (null != assetInfo)
                {
                    package.TryUnloadUnusedAsset(assetInfo);
                }
            }
        }
        /// <inheritdoc />
        public async UniTask<UnityEngine.Object> LoadAssetAsync(string location, Type type, uint priority = 0,
            CancellationToken ct = default)
@@ -426,6 +449,9 @@
            }
            var package = FindPackageForAsset(location);
            Debug.LogError($"[YooAssetService] LoadAssetAsync: Loading asset '{location}' of package '{package.PackageName}'.");
            return await ExecuteWithRetryAsync(async () =>
            {
                var handle = package.LoadAssetAsync(location, type, priority);
@@ -446,23 +472,7 @@
        [System.Obsolete("Use LoadAssetAsync instead. Sync loading will be removed in US2.")]
        public T LoadAssetSync<T>(string location) where T : UnityEngine.Object
        {
            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>();
            throw new NotSupportedException("同步资源加载接口已禁用,请使用异步API");
        }
        /// <inheritdoc />