LoopListViewItem OnGetItemByIndex(LoopListView listView, int index) { if (index < 0 || index >= DataSourceMgr.Get.TotalItemCount) { return(null); } ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(index); if (itemData == null) { return(null); } //get a new item. Every item can use a different prefab, the parameter of the NewListViewItem is the prefab’name. //And all the prefabs should be listed in ItemPrefabList in LoopListView2 Inspector Setting LoopListViewItem item = listView.NewListViewItem("Item"); ListItem itemScript = item.GetComponent <ListItem>(); if (item.IsInitHandlerCalled == false) { item.IsInitHandlerCalled = true; itemScript.Init(); } itemScript.SetItemData(itemData, index); return(item); }
public void OnClick() { HelpInfoItem data = HelpUIView.Instance.GetItemDataByIndex(ItemDataIndex); if (data == null) { return; } IsExpand = !IsExpand; data.isExpand = IsExpand; OnExpandChanged(); LoopListViewItem item = gameObject.GetComponent <LoopListViewItem>(); item.ParentListView.OnItemSizeChanged(item.ItemIndex); }
void LateUpdate() { mLoopListView.UpdateAllShownItemSnapData(); int count = mLoopListView.ShownItemCount; for (int i = 0; i < count; ++i) { LoopListViewItem item = mLoopListView.GetShownItemByIndex(i); ListItem itemScript = item.GetComponent <ListItem>(); float scale = 1 - Mathf.Abs(item.DistanceWithViewPortSnapCenter) / 700f; scale = Mathf.Clamp(scale, 0.4f, 1); itemScript.mContentRootObj.GetComponent <CanvasGroup>().alpha = scale; itemScript.mContentRootObj.transform.localScale = new Vector3(scale, scale, 1); } }