private void UnLoadPackage(string packageName, string winName) { UIPackageAsset package = null; if (!m_PackageLoading.TryGetValue(packageName, out package)) { if (m_PackageAssets.TryGetValue(packageName, out package)) { bool unload = package.UnLoadAssets(winName); if (unload) { List <string> packageDependences = m_PackageDependenceAsset.GetDependencePackages(packageName); for (int i = 0; i < packageDependences.Count; i++) { UnLoadPackage(packageDependences[i], winName); } } } } else { m_PackageLoading.Remove(packageName); bool unload = package.UnLoadAssets(winName); if (unload) { List <string> packageDependences = m_PackageDependenceAsset.GetDependencePackages(packageName); for (int i = 0; i < packageDependences.Count; i++) { UnLoadPackage(packageDependences[i], winName); } } } }
//--------------------------------------------------------------------- private void ProcessShutdownWindows() { for (int index = 0; index < m_ShutdownWindows.Count; ++index) { string name = m_ShutdownWindows[index]; UIWindow win = GetWindow(name); if (win == null || win.IsShow()) { continue; } if (WindowShutdownEvent != null) { WindowShutdownEvent(win); } win.DoShutdown(); m_WindowList.Remove(win); m_ShutdownWindows.Remove(name); --index; //package dont destroy when window shutdown UIPackageAsset package = null; if (m_WindowPackageMap.TryGetValue(win, out package)) { UnLoadPackage(package.name, name); } UnityEngine.Object.Destroy(win.gameObject); m_PackageAssets.Remove(name); m_WindowPackageMap.Remove(win); } }
// Don't allow sub class use follow unity method public void Setup(UIManager mgr, UIPackageAsset package, string name) { this.UIManager = mgr; this.WindowName = name; this.gameObject.name = name; this.package = package; InternalAwake(); }
private void LoadWindowInternal(string packageName, string name) { UIPackageAsset package = LoadPackage(packageName); if (package != null) { package.LoadWindow(name); } }
//--------------------------------------------------------------------- private void AddWindow(UIWindow win, UIPackageAsset package) { if (m_WindowList.Contains(win)) { LOG.Warning(win.GetType().Name + " is the Instance, only one instance."); return; } m_WindowList.Add(win); m_WindowPackageMap.Add(win, package); }
//--------------------------------------------------------------------- internal void TouchWindowLoaded(UIWindow win, UIPackageAsset package) { if (Instance != null) { Instance.AddWindow(win, package); } if (WindowLoadedEvent != null) { WindowLoadedEvent(win); } }
public override void Update() { try{ if (OnCompleted != null && m_PackageDependenceAsset.complete) { OnCompleted(); OnCompleted = null; } for (int index = 0; index < m_WindowList.Count; ++index) { m_WindowList[index].ProcessRequests(); } for (m_PackageLoading.Begin(); m_PackageLoading.Next();) { if (m_PackageLoading.Value.complete) { removeLoading.Add(m_PackageLoading.Key); } } if (removeLoading.Count > 0) { for (int i = 0; i < removeLoading.Count; i++) { //加载依赖包 UIPackageAsset package = m_PackageLoading[removeLoading[i]]; List <string> dependences = m_PackageDependenceAsset.GetDependencePackages(removeLoading[i]); for (int d = 0; d < dependences.Count; d++) { LoadPackageAsync(dependences[d]); } package.ReferenceCount++; m_PackageAssets.Add(removeLoading[i], package); m_PackageLoading.Remove(removeLoading[i]); } removeLoading.Clear(); } ProcessAsyncInvokeList(); if (m_ShutdownWindows.Count != 0) { ProcessShutdownWindows(); } } catch (Exception ex) { Debug.LogError("UIWindow error.msg=" + ex.ToString()); } }
private UIPackageAsset LoadPackageAsync(string packageName) { UIPackageAsset package = null; if (!m_PackageLoading.TryGetValue(packageName, out package)) { if (!m_PackageAssets.TryGetValue(packageName, out package)) { string descPath = string.Format("{0}/{1}_fui.fui", windowFolder, packageName).ToLower(); package = RenderFactory.CreateInstance <UIPackageAsset>(descPath, null, this); m_PackageLoading.Add(packageName, package); } } return(package); }
private UIPackageAsset LoadPackage(string packageName) { UIPackageAsset package = null; if (!m_PackageAssets.TryGetValue(packageName, out package)) { string descPath = string.Format("{0}/{1}_fui.fui", windowFolder, packageName).ToLower(); package = RenderFactory.CreateInstance <UIPackageAsset>(descPath, null, packageName, this, m_PackageDependenceAsset); m_PackageAssets.Add(packageName, package); } //加载依赖包 List <string> dependences = m_PackageDependenceAsset.GetDependencePackages(packageName); for (int d = 0; d < dependences.Count; d++) { LoadPackage(dependences[d]); } package.ReferenceCount++; return(package); }