96 lines
2.8 KiB
C#
Raw Normal View History

2025-06-07 17:43:34 +08:00
// Author: 文若
// CreateDate: 2022/10/26
using UnityEngine;
using UnityEngine.UI;
namespace RV
{
public class RecycleViewTest : MonoBehaviour
{
public int ListCount = 1000;
public int gotoIndex = 0;
public RecycleView VerticalScroll;
public RecycleView HorizontalScroll;
public ExpandableView ExpandScroll;
public Button logBtn;
public Button goToIndexBtn;
public ExpandableViewSingle Ev_menu;
void Start()
{
StartScrollView();
logBtn.onClick.AddListener(ShowLog);
goToIndexBtn.onClick.AddListener(GotoIndex);
}
public void StartScrollView()
{
VerticalScroll.Init(NormalCallBack);
VerticalScroll.ShowList(ListCount);
HorizontalScroll.Init(NormalCallBack);
HorizontalScroll.ShowList(ListCount);
ExpandScroll.Init(ExpandCallBack);
ExpandScroll.ShowList("3|2|5|8");
Ev_menu.Init(Ev_ExpandCallBack);
Ev_menu.ShowList("0|3|6|3|2|3|2");
//Ev_menu.OnShowExpand_Idx(0);
Ev_menu.Init_Click(ClickCallBack);
Ev_menu.OnCloseAllTitle();
}
int last = 0;
GameObject ga111;
private async void ClickCallBack(int idx, bool isExpand, GameObject ga, bool isClick)
{
if (ga111 != null)
Ev_menu.OnClickCell_Un(ga111);
ga111 = ga;
//Ev_menu.OnShowExpand_Idx(idx - 1);
//LogPink($"ClickCallBack {idx} {b} {ga}");
}
private void Ev_ExpandCallBack(GameObject cell, GameObject childCell, int index, int childIndex, bool isExpand)
{
//cell.transform.Find("Text1").GetComponent<Text>().text = "Btn : " + index.ToString();
//if (childCell != null)
//{
// childCell.transform.Find("Text1").GetComponent<Text>().text = childIndex.ToString();
//}
}
private void NormalCallBack(GameObject cell, int index)
{
cell.transform.Find("Text1").GetComponent<Text>().text = index.ToString();
}
private void ExpandCallBack(GameObject cell, GameObject childCell, int index, int childIndex, bool isExpand)
{
cell.transform.Find("Text1").GetComponent<Text>().text = "Btn : " + index.ToString();
if (childCell != null)
{
childCell.transform.Find("Text1").GetComponent<Text>().text = childIndex.ToString();
}
}
void ShowLog()
{
#if UNITY_EDITOR
VerticalScroll.LogRecycleView();
#endif
}
void GotoIndex()
{
VerticalScroll.GoToCellPos(gotoIndex);
HorizontalScroll.GoToCellPos(gotoIndex);
}
}
}