示例#1
0
        public virtual UICtrlBase CreateUI(Type type)
        {
            UICtrlBase ctrl = GetUI(type);

            //还没创建ctrl
            if (ctrl == null)
            {
                ctrl = CreateCtrl(type);
            }
            else
            {
                if (ctrl.IsViewCreated)
                {
                    return(ctrl);
                }
            }

            if (ctrl == null)
            {
                //做一些处理
                return(null);
            }

            UIViewBase view = InstanceView(type);

            if (view == null)
            {
                return(null);
            }

            //放在group里面
            CommonTools.SetParent(view.Trans, _uiGroups[ctrl.GroupId].Trans);
            ctrl.SetView(view);
            return(ctrl);
        }
示例#2
0
        public virtual UICtrlBase CloseUI(Type ctrlType)
        {
            if (UIRoot == null)
            {
                return(null);
            }

            UICtrlBase ctrl = UIRoot.GetUI(ctrlType);

            if (ctrl.IsViewCreated)
            {
                ctrl.Close();
            }

            return(ctrl);
        }
示例#3
0
        public virtual UICtrlBase OpenUI(Type ctrlType, object value = null)
        {
            if (UIRoot == null)
            {
                return(null);
            }

            UICtrlBase ctrl = UIRoot.GetUI(ctrlType);

            if (ctrl.IsViewCreated)
            {
                ctrl.Open(value);
            }
            else
            {
                UIRoot.CreateUI(ctrlType);
                ctrl.Open(value);
            }

            return(ctrl);
        }
示例#4
0
        public virtual UICtrlBase CreateCtrl(Type type)
        {
            if (type == null)
            {
                LogHelper.Error("CreateCtrl called but type is null!!");
                return(null);
            }

            string     typeName = type.ToString();
            UICtrlBase ctrl     = GetUI(type);

            if (ctrl != null)
            {
                LogHelper.Error("CreateCtrl T {0} but has exist!", typeName);
                return(ctrl);
            }

            ctrl = (UICtrlBase)Activator.CreateInstance(type);
            ctrl.Awake();
            _allUIs.Add(typeName, ctrl);
            return(ctrl);
        }