protected override void Unbind() { m_OnItemCreate = null; m_OnItemInit = null; m_OnItemClick = null; base.Unbind(); }
protected override void Unbind() { m_ItemCount = 0; m_Items.Clear(); m_OnItemCreate = null; m_OnItemInit = null; m_OnItemClick = null; base.Unbind(); }
public override void Bind(LuaTable table) { base.Bind(table); m_OnScrollStart = Table.Get <DelegateGameObjectInt>("OnScrollStart"); m_OnScrollEnd = Table.Get <DelegateGameObjectInt>("OnScrollEnd"); m_ScrollView = GetComponent <GScrollView>(); m_ScrollView.Init(OnScrollStart, OnScrollEnd); }
public override void Bind(LuaTable table) { base.Bind(table); m_OnItemCreate = Table.Get <Action <LuaTable, GameObject> >("OnItemCreate"); m_OnItemInit = Table.Get <DelegateGameObjectInt>("OnItemInit"); m_OnItemClick = Table.Get <DelegateGameObjectInt>("OnItemClick"); var tag = gameObject.name; var idx = tag.IndexOf("_Simple") + 7; var n = tag.Substring(idx, tag.Length - idx); m_ItemCount = int.Parse(n); m_Items = new List <GItem>(m_ItemCount); var template = transform.GetChild(0).gameObject; var templateItem = template.GetComponent <GItem>(); if (templateItem == null) { templateItem = template.AddComponent <GItem>(); templateItem.Register(OnItemInit, OnItemClick); } m_Items.Add(templateItem); for (int i = 1; i < m_ItemCount; i++) { var dup = GameObject.Instantiate(template); dup.transform.SetParent(transform); dup.transform.localScale = Vector3.one; dup.transform.localRotation = Quaternion.identity; var itc = dup.GetComponent <GItem>(); if (itc == null) { itc = dup.AddComponent <GItem>(); } itc.Register(OnItemInit, OnItemClick); m_Items.Add(itc); } foreach (var itm in m_Items) { OnItemCreate(itm.gameObject); } }
public override void Bind(LuaTable table) { base.Bind(table); m_OnItemCreate = Table.Get <Action <LuaTable, GameObject> >("OnItemCreate"); m_OnItemInit = Table.Get <DelegateGameObjectInt>("OnItemInit"); m_OnItemClick = Table.Get <DelegateGameObjectInt>("OnItemClick"); var grid = GetComponent <GridLayoutGroup>(); var rectGrid = grid.transform as RectTransform; var width = rectGrid.sizeDelta.x; var padding = grid.padding.left + grid.padding.right; var spacing = grid.spacing.x; var cell = grid.cellSize.x; var noc = Mathf.RoundToInt((width + spacing - padding) / (cell + spacing)); width = rectGrid.sizeDelta.y; padding = grid.padding.top + grid.padding.bottom; spacing = grid.spacing.y; cell = grid.cellSize.y; var nor = Mathf.RoundToInt((width + spacing - padding) / (cell + spacing)); var container = transform.Find("container"); var scroll = GetComponent <ScrollRect>(); scroll.content = container as RectTransform; m_List = container.gameObject.AddComponent <GList>(); m_List.NumberOfRow = nor; m_List.NumberOfColumn = noc; m_List.Spacing = grid.spacing; m_List.CurrentDirection = grid.startAxis; m_List.m_Cell = transform.GetChild(0) as RectTransform; m_List.m_Cell.sizeDelta = grid.cellSize; m_List.OnCreateItem = OnItemCreate; m_List.OnInitItem = OnItemInit; m_List.OnClickItem = OnItemClick; m_List.Init(); Destroy(grid); Destroy(container.GetComponent <LayoutElement>()); }
protected override void Unbind() { m_OnScrollStart = null; m_OnScrollEnd = null; base.Unbind(); }