You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
using DG.Tweening; |
|
using OneP.InfinityScrollView; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class ListViewer : MonoBehaviour |
|
{ |
|
RectTransform rect; |
|
public InfinityScrollView infinityScroll; |
|
|
|
public bool INIT = false; |
|
System.Action<string> OnSelect; |
|
public void OnInitialized(List<string> strs, System.Action<string> OnSelect) |
|
{ |
|
if (rect == null) |
|
rect = GetComponent<RectTransform>(); |
|
|
|
this.OnSelect = OnSelect; |
|
this.strs = strs; |
|
|
|
StartCoroutine(Initialized()); |
|
} |
|
public List<ListViewerItem> items; |
|
IEnumerator Initialized() |
|
{ |
|
yield return null; |
|
|
|
if (!INIT) |
|
{ |
|
ListViewerItem item = null; |
|
for (int i = 0; i < infinityScroll.listItem.Count; i++) |
|
{ |
|
item = infinityScroll.listItem[i].GetComponent<ListViewerItem>(); |
|
item.OnGeted = DataGet; |
|
item.OnSelect = OnSelect; |
|
|
|
items.Add(item); |
|
} |
|
|
|
yield return null; |
|
|
|
INIT = true; |
|
} |
|
|
|
LoadAsync(); |
|
} |
|
void LoadAsync() |
|
{ |
|
infinityScroll.Setup(strs.Count); |
|
infinityScroll.InternalReload(); |
|
} |
|
|
|
public List<string> strs; |
|
string DataGet(int i) |
|
{ |
|
return strs[i]; |
|
} |
|
}
|
|
|