/// <summary> /// 异步加载场景 /// </summary> public AssetOperationHandle LoadSceneAsync(string location, SceneInstanceParam instanceParam) { string sceneName = Path.GetFileName(location); FileLoaderBase cacheLoader = AssetSystem.CreateLoader(location); var handle = cacheLoader.LoadSceneAsync(sceneName, instanceParam); return(handle); }
/// <summary> /// 强制回收所有资源 /// </summary> public static void ForceUnloadAllAssets() { for (int i = 0; i < _loaders.Count; i++) { FileLoaderBase loader = _loaders[i]; loader.Destroy(false); } _loaders.Clear(); // 释放所有资源 Resources.UnloadUnusedAssets(); }
/// <summary> /// 资源回收(卸载引用计数为零的资源) /// </summary> public static void UnloadUnusedAssets() { for (int i = _loaders.Count - 1; i >= 0; i--) { FileLoaderBase loader = _loaders[i]; if (loader.CanDestroy()) { loader.Destroy(true); _loaders.RemoveAt(i); } } }
/// <summary> /// 实时销毁场景 /// 注意:因为场景比较特殊,需要立刻回收 /// </summary> private static void UpdateDestroyScene() { for (int i = _loaders.Count - 1; i >= 0; i--) { FileLoaderBase loader = _loaders[i]; if (loader.IsSceneLoader && loader.CanDestroy()) { loader.Destroy(true); _loaders.RemoveAt(i); } } }
private AssetOperationHandle LoadSubAssetsInternal(string location, System.Type assetType, bool waitForAsyncComplete) { string assetName = Path.GetFileName(location); FileLoaderBase cacheLoader = AssetSystem.CreateLoader(location); var handle = cacheLoader.LoadSubAssetsAsync(assetName, assetType, waitForAsyncComplete); if (waitForAsyncComplete) { cacheLoader.WaitForAsyncComplete(); } return(handle); }
/// <summary> /// 从列表里获取加载器 /// </summary> private static FileLoaderBase TryGetLoader(string bundleName) { FileLoaderBase loader = null; for (int i = 0; i < _loaders.Count; i++) { FileLoaderBase temp = _loaders[i]; if (temp.BundleInfo.BundleName.Equals(bundleName)) { loader = temp; break; } } return(loader); }
internal static FileLoaderBase CreateLoaderInternal(AssetBundleInfo bundleInfo) { // 如果加载器已经存在 FileLoaderBase loader = TryGetLoader(bundleInfo.BundleName); if (loader != null) { return(loader); } // 创建加载器 if (SimulationOnEditor) { loader = new AssetDatabaseLoader(bundleInfo); } else { loader = new AssetBundleLoader(bundleInfo); } // 新增下载需求 _loaders.Add(loader); return(loader); }
public AssetBundleProvider(FileLoaderBase owner, string assetName, System.Type assetType) : base(owner, assetName, assetType) { _loader = owner as AssetBundleLoader; }
public AssetSceneProvider(FileLoaderBase owner, string assetName, SceneInstanceParam param) : base(owner, assetName, null) { _param = param; }
public AssetDatabaseProvider(FileLoaderBase owner, string assetName, System.Type assetType) : base(owner, assetName, assetType) { }