Ejemplo n.º 1
0
        private void OpenWindow(string resPath, Transform parent, UICallback callback)
        {
            UIBaseWindow window = null;

            if (_windowPool.TryGetValue(resPath, out var win))
            {
                win.gameObject.SetActive(true);
                window = win;
                _windowPool.Remove(resPath);
            }
            else
            {
                var prefab = Resources.Load <GameObject>(_prefabDir + resPath);
                if (prefab == null)
                {
                    Logging.Debug.LogError("OpenWindow failed: can not find prefab" + resPath);
                    callback?.Invoke(null);
                    return;
                }

                var uiGo = GameObject.Instantiate(prefab, parent);
                window         = uiGo.GetOrAddComponent <UIBaseWindow>();
                window.ResPath = resPath;
            }

            openedWindows.Add(window);
            window.DoAwake();
            window.DoStart();
            window.uiService = this;
            _eventRegisterService.RegisterEvent(window);
            callback?.Invoke(window);
        }
Ejemplo n.º 2
0
        // Token: 0x060000AA RID: 170 RVA: 0x00005D28 File Offset: 0x00003F28
        private void RegisterEventButton(object objWin, string compName, UnityAction action)
        {
            UIBaseWindow uibaseWindow = (UIBaseWindow)objWin;
            Button       @ref         = uibaseWindow.GetRef <Button>(compName);
            bool         flag         = @ref != null;

            if (flag)
            {
                @ref.onClick.RemoveListener(action);
                @ref.onClick.AddListener(action);
            }
            else
            {
                Debug.Log(uibaseWindow.GetType() + " miss ref " + compName);
            }
        }
Ejemplo n.º 3
0
        // Token: 0x060000A9 RID: 169 RVA: 0x00005CC4 File Offset: 0x00003EC4
        private void RegisterEventToggle(object objWin, string compName, UnityAction <bool> action)
        {
            UIBaseWindow uibaseWindow = (UIBaseWindow)objWin;
            Toggle       @ref         = uibaseWindow.GetRef <Toggle>(compName);
            bool         flag         = @ref != null;

            if (flag)
            {
                @ref.onValueChanged.RemoveListener(action);
                @ref.onValueChanged.AddListener(action);
            }
            else
            {
                Debug.Log(uibaseWindow.GetType() + " miss ref " + compName);
            }
        }
Ejemplo n.º 4
0
 public void CloseWindow(UIBaseWindow window)
 {
     if (window != null)
     {
         //unbind Msgs
         window.OnClose();
         _eventRegisterService.UnRegisterEvent(window);
         if (_windowPool.ContainsKey(window.ResPath))
         {
             GameObject.Destroy(window.gameObject);
         }
         else
         {
             window.gameObject.SetActive(false);
             _windowPool[window.ResPath] = window;
         }
     }
 }
Ejemplo n.º 5
0
        // Token: 0x060000A0 RID: 160 RVA: 0x00005928 File Offset: 0x00003B28
        public void CloseWindow(UIBaseWindow window)
        {
            bool flag = window != null;

            if (flag)
            {
                window.OnClose();
                this.openedWindows.Remove(window);
                this._eventRegisterService.UnRegisterEvent(window);
                bool flag2 = this._windowPool.ContainsKey(window.ResPath);
                if (flag2)
                {
                    Object.Destroy(window.gameObject);
                }
                else
                {
                    window.gameObject.SetActive(false);
                    this._windowPool[window.ResPath] = window;
                }
            }
        }