public static void LoadUI(string uipath) { if (string.IsNullOrEmpty(uipath)) { return; } AssetBundle ab = null; if (m_abDir.ContainsKey(uipath)) { ab = m_abDir[uipath]; } if (null == ab) { ab = ABLoader.GetUIAssetBundle(uipath); m_abDir.Remove(uipath); if (null != ab) { m_abDir.Add(uipath, ab); } } string id = uipath; if (m_pkgDir.ContainsKey(uipath)) { id = m_pkgDir[uipath]; } UIPackage pkg = UIPackage.GetById(id); if (null == pkg) { if (null == ab) { pkg = UIPackage.AddPackage(uipath); } else { pkg = UIPackage.AddPackage(ab); } } else { if (null == ab) { pkg.ReloadAssets(); } else { pkg.ReloadAssets(ab); } } if (!m_pkgDir.ContainsKey(uipath)) { m_pkgDir.Add(uipath, pkg.id); } }
/// <summary> /// fgui独立管理ab,接口单独拎出来! /// </summary> public static void LoadUI(string uipath) { AssetBundle ab = null; // 检测是否存在ab if (null != ABVersion.CurVersionInfo && ABVersion.CurVersionInfo.IsValid) { string abname = ABHelper.GetFileFolderPath(uipath) + ".ab"; string uiFullPath = ABVersion.CurVersionInfo.GetABFullPath(abname); if (!string.IsNullOrEmpty(uiFullPath)) { ab = AssetBundle.LoadFromFile(uiFullPath); } } UIPackage pkg = UIPackage.GetByName(uipath); if (null == pkg) { if (null == ab) { pkg = UIPackage.AddPackage(uipath); } else { pkg = UIPackage.AddPackage(ab); } } else { if (null == ab) { pkg.ReloadAssets(); } else { pkg.ReloadAssets(ab); } } }
/// <summary> /// 重新加载包的资源进入内存。 /// </summary> /// <param name="packageName">包名</param> public void ReloadAssets(string packageName) { try { UIPackage package = UIPackage.GetByName(packageName); package.ReloadAssets(); } catch (Exception e) { Debug.LogError("资源加载错误,请检查是否在调用了DestroyAllWindow方法后又调用了OpenWindow方法:" + e); #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #endif } }
public void ReloadAssets(string packageName) { try { UIPackage package = UIPackage.GetByName(packageName); package.ReloadAssets(); } catch (Exception e) { Debug.LogError("资源加载错误,请检查是否在调用了UIWindowManager.Instance.DestoryAllWindow()方法后又调用了UIWindowManager.Instance.OpenWindow()方法,错误代码:AA0012"); #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #endif return; } }
protected override void OnUpdate() { if (!complete || package == null) { return; } if (loadingWins.Count > 0) { for (int i = 0; i < loadingWins.Count; i++) { ReferenceCount++; CreateWindowAsync(package.name, loadingWins[i]); } loadingWins.Clear(); } if (loading.Count > 0) { for (loading.Begin(); loading.Next();) { var dependence = loading.Value; if (dependence.complete) { dependences.Add(dependence.name, dependence); loadComplets.Add(loading.Key); } } for (int i = 0; i < loadComplets.Count; i++) { loading.Remove(loadComplets[i]); } loadComplets.Clear(); if (loading.Count == 0) { package.ReloadAssets(); } } }