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); }
public void RemoveComponent(GameUIComponent comp) { if (comp.LogicHandler == this) { components.Remove(comp); needSync = true; } }
public void AddComponent(GameUIComponent comp) { if (comp.LogicHandler == this) { components.Add(comp); needSync = true; } }
public void Init(GUIFrame guiFrame) { AutoDestroy = true; this.UIFrame = guiFrame; this.m_rootComponent = Make <GameUIComponent>(root); InitBuildinUIEffect(); OnInit(); }
public void Make(string name, GameUIComponent ui) { ui.LogicHandler = this; bool bFind = ui.Init(name, root); if (bFind) { AddComponent(ui); } }
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); } } }
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); }
/// <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); }
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); }
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); }
protected virtual void SetTipUI(GameUIComponent tipUI, string source) { this.tipUI = tipUI; this.sourceID = source; }