Ejemplo n.º 1
0
        public void LoadWindow(string windowName, bool isBackground = false, WindowLoadFinishHandle callback = null)
        {
            WindowInfo windowInfo = WindowInfoTable.Instance.GetWindowInfo(windowName);

            if (windowInfo != null)
            {
                ResourceRequest request = Resources.LoadAsync(windowInfo.path);
                WindowLoadInfo  info    = new WindowLoadInfo();
                info.mResourceRequest = request;
                info.info             = windowInfo;
                info.isBackground     = isBackground;
                info.callback         = callback;
                mWindowLoadInfoList.Add(info);
            }
        }
Ejemplo n.º 2
0
 public void Update(float deltaTime)
 {
     for (int i = mWindowLoadInfoList.Count - 1; i >= 0; i--)
     {
         WindowLoadInfo  loadInfo = mWindowLoadInfoList[i];
         ResourceRequest request  = loadInfo.mResourceRequest;
         if (request.isDone)
         {
             GameObject  prefab     = request.asset as GameObject;
             WindowInfo  info       = loadInfo.info;
             System.Type windowType = System.Type.GetType("LClient." + info.className);
             if (windowType != null)
             {
                 BaseWindow window   = (BaseWindow)System.Activator.CreateInstance(windowType);
                 GameObject instance = GameObject.Instantiate(prefab);
                 if (mCanvas.ContainsKey(info.layer))
                 {
                     RectTransform rect = instance.GetComponent <RectTransform>();
                     rect.SetParent(mCanvas[info.layer], false);
                     if (!loadInfo.isBackground)
                     {
                         window.Create(instance, true);
                         mFrontWindows.Add(info.name, window);
                     }
                     else
                     {
                         window.Create(instance, false);
                         mBackgroundWindows.Add(info.name, window);
                     }
                     WindowLoadFinishHandle callback = loadInfo.callback;
                     if (callback != null)
                     {
                         callback.Invoke(window);
                     }
                 }
             }
             mWindowLoadInfoList.RemoveAt(i);
         }
     }
 }