Esempio n. 1
0
        private WindowRequest loadWindowAsync(string windowName)
        {
            WindowRequest wr = new WindowRequest();

            wr.source = WindowResSource.Unknown;

            ZGame.Res.AsyncOperation ao = new ZGame.Res.AsyncOperation();
            wr.source = WindowResSource.Newborn;

            if (windowResType == WindowResType.AssetBundle)
            {
                //uiObj = ABManager.Instance.LoadWindow(info.resName);
            }
            else if (windowResType == WindowResType.Prefab)
            {
                ResHelper.Instance.LoadModelAsync("Window/" + windowName, (uiObj) =>
                {
                    Type t        = Type.GetType(windowName);
                    Window target = Activator.CreateInstance(t, new object[] { uiObj, windowName }) as Window;

                    wr.asset  = target;
                    ao.isDone = true;
                    wr.OnComplete(ao);
                });
            }

            return(wr);
        }
Esempio n. 2
0
 public void OnComplete(ZGame.Res.AsyncOperation ao)
 {
     if (this.onCompleted != null)
     {
         this.onCompleted(ao);
     }
 }
Esempio n. 3
0
        WindowRequest genTargetWindowAsync(string windowName)
        {
            WindowRequest wr = new WindowRequest();

            wr.source = WindowResSource.Unknown;

            ZGame.Res.AsyncOperation ao = new ZGame.Res.AsyncOperation();


            WindowInfos.TryGetValue(windowName, out WindowInfo info);
            if (info == null)
            {
                Debug.LogError("error, " + windowName + " is not registed");
                wr.source = WindowResSource.Unknown;
                return(wr);
            }

            Window target = null;

            if (openedWindows.ContainsKey(windowName))
            {
                Debug.LogError("window: " + windowName + ", has already opened!");
                wr.source = WindowResSource.Opened;
                target    = openedWindows[windowName];
                wr.asset  = target;
                ao.isDone = true;
                wr.OnComplete(ao);
                return(wr);
            }
            else
            {
                if (cachedWindows.ContainsKey(windowName))
                {
                    wr.source = WindowResSource.Cache;
                    target    = cachedWindows[windowName];
                    wr.asset  = target;
                    ao.isDone = true;
                    wr.OnComplete(ao);
                    return(wr);
                }
                else
                {
                    return(loadWindowAsync(windowName));
                }
            }
        }