/// <summary> /// 初始化 /// </summary> /// <param name="loaderMode">加载方式</param> /// <param name="pathMode">路径方式</param> /// <param name="maxLoadingCount">同时加载的最大数量</param> /// <param name="assetRootDir">资源存放根路径</param> /// <param name="initCallback">回调</param> public void InitLoader(AssetLoaderMode loaderMode, AssetPathMode pathMode, int maxLoadingCount, string assetRootDir, Action <bool> initCallback) { Leyoutech.Utility.DebugUtility.Log(LOG_TAG, $"Begin init loader AssetLoaderMode({loaderMode}) AssetPathMode({pathMode}) MaxLoadingCount({maxLoadingCount}) AssetRootDir({assetRootDir})"); if (loaderMode == AssetLoaderMode.AssetBundle) { m_AssetLoader = new AssetBundleLoader(); } else if (loaderMode == AssetLoaderMode.AssetDatabase) { m_AssetLoader = new AssetDatabaseLoader(); #if !UNITY_EDITOR Debug.LogError("AssetManager::InitLoader->AssetLoaderMode(AssetDatabase) can be used in Editor"); #endif } m_AssetLoader?.Initialize((isSuccess) => { m_IsInit = isSuccess; if (isSuccess) { m_SceneLoader = new SceneAssetLoader(loaderMode, m_AssetLoader); } Leyoutech.Utility.DebugUtility.Log(LOG_TAG, "End init loader"); initCallback?.Invoke(isSuccess); }, pathMode, maxLoadingCount, assetRootDir); }
/// <summary> /// 初始化资源加载器。 /// 在使用前必须先进行初始化,初始成功后才能正常使用 /// </summary> /// <param name="mode">资源加载模式,参见<see cref="AssetLoaderMode"/></param> /// <param name="initCallback">管理器初始化成功后回调,成功返回true,否则返回false</param> /// <param name="assetRootDir">使用AB加载资源时,需要指定AB资源所在的根目录</param> public void InitManager(AssetLoaderMode mode, Action <bool> initCallback, string assetRootDir = "") { loaderMode = mode; DebugLog.Info(AssetConst.LOGGER_NAME, $"AssetManager::InitManager->Start init mgr.mode = {mode.ToString()},assetRootDir = {assetRootDir}"); if (loaderMode == AssetLoaderMode.AssetBundle) { assetLoader = new BundleLoader(); } #if UNITY_EDITOR else { assetLoader = new DatabaseLoader(); } #endif if (assetLoader == null) { DebugLog.Error(AssetConst.LOGGER_NAME, "AssetLoader is Null"); initCallback?.Invoke(false); } else { assetLoader.Initialize((Action <bool>)((result) => { if (!result) { DebugLog.Error((string)AssetConst.LOGGER_NAME, "AssetManager::InitManager->init failed"); } DebugLog.Info((string)AssetConst.LOGGER_NAME, "AssetManager::InitManager->init Success"); if (loaderMode == AssetLoaderMode.AssetBundle) { sceneLoader = new BundleSceneLoader(assetLoader); } #if UNITY_EDITOR else { sceneLoader = new DatabaseSceneLoader(assetLoader); } #endif if (result) { StartAutoClean(); } initCallback.Invoke(result); }), assetRootDir); } }
private List <SceneUnloadData> m_UnloadingSceneDatas = new List <SceneUnloadData>(); //卸载中的场景的数据 public SceneAssetLoader(AssetLoaderMode loaderMode, AAssetLoader assetLoader) { this.m_LoaderMode = loaderMode; this.m_AssetLoader = assetLoader; }