示例#1
0
        public GameObject AddChild()
        {
            GameObject go = null;

            if (_usePool)
            {
                GameUIComponent ui = childPool.Alloc();
                if (ui != null)
                {
                    go = ui.gameObject;
                    Vector3 sc = ui.Widget.localScale;
                    Vector3 ps = ui.Widget.anchoredPosition3D;
                    ui.Widget.SetParent(ContainerTransform);
                    ui.Widget.localScale         = sc;
                    ui.Widget.anchoredPosition3D = ps;
                    ui.Widget.localRotation      = Quaternion.identity;
                    ui.FromPool = true;
                    ui.Visible  = true;
                }
            }
            if (go == null)
            {
                go = GOGUITools.AddChild(ContainerTransform, ContainerTemplate).gameObject;

                go.SetActive(this.m_templateVisiable);
            }
            childListDirty = true;
            return(go);
        }
示例#2
0
 public void RemoveComponent(GameUIComponent comp)
 {
     if (comp.LogicHandler == this)
     {
         components.Remove(comp);
         needSync = true;
     }
 }
示例#3
0
 public void AddComponent(GameUIComponent comp)
 {
     if (comp.LogicHandler == this)
     {
         components.Add(comp);
         needSync = true;
     }
 }
示例#4
0
        public void Init(GUIFrame guiFrame)
        {
            AutoDestroy          = true;
            this.UIFrame         = guiFrame;
            this.m_rootComponent = Make <GameUIComponent>(root);

            InitBuildinUIEffect();

            OnInit();
        }
示例#5
0
        public void Make(string name, GameUIComponent ui)
        {
            ui.LogicHandler = this;
            bool bFind = ui.Init(name, root);

            if (bFind)
            {
                AddComponent(ui);
            }
        }
示例#6
0
        public override void EnsureSize <T>(int count)
        {
            base.EnsureSize <T>(count);

            for (int i = 0; i < ChildCount; ++i)
            {
                GameUIComponent childElement = GetChild <GameUIComponent>(i);
                if (!childElement.Visible)
                {
                    m_avaliableElementQueue.Enqueue(childElement);
                }
            }
        }
示例#7
0
 public static void Make(GameUIComponent com, string id, GameObject root, UILogicBase logic, GameUIComponent parent)
 {
     if (parent != null)
     {
         parent.children.Add(com);
     }
     if (logic != null)
     {
         com.LogicHandler = logic;
         logic.AddComponent(com);
     }
     com.Init(id, root);
 }
示例#8
0
        /// <summary>
        /// 获取可用容器对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T GetAvaliableContainerElement <T>() where T : GameUIComponent, new()
        {
            if (m_avaliableElementQueue.Count == 0)
            {
                for (int i = 0; i < AllocPertime; ++i)
                {
                    GameUIComponent childElement = AddChild <T>();
                    m_avaliableElementQueue.Enqueue(childElement);
                }
            }

            T avaliableElement = m_avaliableElementQueue.Dequeue() as T;

            return(avaliableElement);
        }
示例#9
0
        public static T Make <T>(string id, GameObject root, UILogicBase logic, GameUIComponent parent = null) where T : GameUIComponent, new()
        {
            T com = new T();

            if (parent != null)
            {
                parent.Children.Add(com);
            }
            if (logic != null)
            {
                com.LogicHandler = logic;
                logic.AddComponent(com);
            }
            com.Init(id, root);
            if (com.gameObject == null)
            {
                return(null);
            }
            return(com);
        }
示例#10
0
        protected GameUIComponent DisposeChild(GameObject child)
        {
            GameUIComponent ui = child.ToGameUIComponent();

            childListDirty = true;
            if (_usePool)
            {
                if (childPool.Free(ui))
                {
                    if (ui != null)
                    {
                        ui.Visible = false;
                    }
                    else
                    {
                        child.SetActive(false);
                    }
                    Vector3 sc = child.transform.localScale;
                    Vector3 ps = child.transform.localPosition;
                    child.transform.SetParent(poolTransform);
                    child.transform.localScale    = sc;
                    child.transform.localPosition = ps;
                    return(ui);
                }
            }
            if (ui != null)
            {
                if (ui.Visible)
                {
                    ui.OnHide();
                }
                ui.Dispose(false);
            }
            child.transform.SetParent(null);
            GameObject.Destroy(child);
            return(ui);
        }
示例#11
0
 protected virtual void SetTipUI(GameUIComponent tipUI, string source)
 {
     this.tipUI    = tipUI;
     this.sourceID = source;
 }