Beispiel #1
0
        private void UpdateListItem(ListItemData listItem)
        {
            GameObject item;

            if (listItem.Item == null)
            {
                item = this.DataSource.ListViewItem(listItem.Position, null);
                Assert.IsNotNull(item, "ListItem is null!!");
                item.name = "ListItem";
                listItem.SetItemObjcet(item);
                var itemRectTransform = item.GetComponent <RectTransform>();
                itemRectTransform.anchorMin = new Vector2(0, 0);
                itemRectTransform.anchorMax = new Vector2(1, 1);

                var clickHandler = item.GetComponent <ClickHandler>() ?? item.AddComponent <ClickHandler>();
                clickHandler.callback = (gameObject) => {
                    this.TapItem(gameObject);
                };
            }
            else
            {
                item = this.DataSource.ListViewItem(listItem.Position, listItem.Item);
            }
            item.SetActive(true);
        }
Beispiel #2
0
        private void UpdateListItem(ListItemData listItem)
        {
            GameObject item;

            if (listItem.Item == null)
            {
                item = this.DataSource.CellViewItem(listItem.Position, null);
                Assert.IsNotNull(item, "ListItem is null!!");
                item.name = "ListItem";
                listItem.SetItemObjcet(item);
                var itemRectTransform = item.GetComponent <RectTransform>();
                itemRectTransform.anchorMin = new Vector2(0, 0);
                itemRectTransform.anchorMax = new Vector2(1, 1);

                var clickHandler = item.GetComponent <PointerHandler>() ?? item.AddComponent <PointerHandler>();
                clickHandler.callback = (gameObject, e) => {
                    switch (e)
                    {
                    case PointerHandler.Event.Click:
                        this.TapItem(gameObject);
                        break;

                    case PointerHandler.Event.Press:
                        this.PressItem(gameObject);
                        break;
                    }
                };
            }
            else
            {
                item = this.DataSource.CellViewItem(listItem.Position, listItem.Item);
            }
            item.SetActive(true);
        }