//-------------------------------------------------------------------------------------------------- // Function: Clear // // Description: //-------------------------------------------------------------------------------------------------- static void Clear() { m_Config = null; m_Complete = null; }
/// <summary> /// 异步加载预置体 /// </summary> /// <param name="stateName">状态名称</param> /// <param name="finish">加载完成回调</param> public static void LoadHudAsync(string stateName, HudLoadComplete finish) { Completed = false; HideAll(); HudLoadConfig config = GetHudLoadConfig(stateName); if (config != null) { Clear(); // List <string> toLoad = new List <string>(); List <string> toUnload = new List <string>(); // find what to load for (int i = 0; i < config.Load.Length; ++i) { toLoad.Add(config.Load[i]); } // find what to unload for (int i = 0; i < m_HudToLoad.Count; ++i) { string hudName = m_HudToLoad[i]; bool found = false; for (int j = 0; j < toLoad.Count; ++j) { if (hudName == toLoad[j]) { found = true; break; } } if (!found) { toUnload.Add(hudName); } } // destroy all hud that is not needed for (int i = 0; i < toUnload.Count; ++i) { DestroyHud(toUnload[i]); } // sync load all hud that is needed m_HudToLoad = toLoad; m_Config = config; m_Complete = finish; EB.Debug.Log("[HudLoadManager]LoadHudAsync: Length = {0}", m_HudToLoad.Count.ToString()); m_LoadIndex = 0; //// serial load //LoadHudAsyncImpl(m_HudToLoad[m_LoadIndex], OnLoadFailed, OnLoadFinish); //parallel load for (int i = 0; i < m_HudToLoad.Count; ++i) { LoadHudAsyncImpl(m_HudToLoad[i], OnParallelLoadFailed, OnParallelLoadFinish); } } else { EB.Debug.LogError("[HudLoadManager]LoadHudAsync: There is no config for {0}", stateName); } }