80 lines
2.5 KiB
C#
80 lines
2.5 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class uScrollViewArrMgr : BackKeyAdd
|
|
{
|
|
public ScrollRect[] m_scrollview;
|
|
public GameObject[] m_content;
|
|
public GameObject[] go_card;
|
|
|
|
protected List<Transform> list_cardParent = new List<Transform>();
|
|
protected Dictionary<int, List<CardBase>> dic_cardbase = new Dictionary<int, List<CardBase>>();
|
|
|
|
void Init()
|
|
{
|
|
if (list_cardParent.Count == 0)
|
|
{
|
|
if (!DSUtil.CheckNull(m_scrollview) && m_scrollview.Length > 0)
|
|
{
|
|
for (int i = 0; i < m_scrollview.Length; i++)
|
|
{
|
|
list_cardParent.Add(m_scrollview[i].content);
|
|
dic_cardbase.Add(i, new List<CardBase>());
|
|
}
|
|
}
|
|
else if (!DSUtil.CheckNull(m_content) && m_content.Length > 0)
|
|
{
|
|
for (int i = 0; i < m_content.Length; i++)
|
|
{
|
|
list_cardParent.Add(m_content[i].transform);
|
|
dic_cardbase.Add(i, new List<CardBase>());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void CardBase_AllOff(int _index)
|
|
{
|
|
Init();
|
|
for (int i = 0; i < dic_cardbase[_index].Count; i++)
|
|
dic_cardbase[_index][i].gameObject.SetActive(false);
|
|
}
|
|
|
|
CardBase MakeCard(int _index, int i)
|
|
{
|
|
CardBase temp;
|
|
if (dic_cardbase[_index].Count > i) temp = dic_cardbase[_index][i];
|
|
else
|
|
{
|
|
temp = DSUtil.Get_Clone<CardBase>(go_card[_index], list_cardParent[_index]);
|
|
dic_cardbase[_index].Add(temp);
|
|
}
|
|
|
|
return temp;
|
|
}
|
|
|
|
protected virtual void Set_ScrollView<T>(int _index, List<T> _lst, bool offotherscroll)
|
|
{
|
|
CardBase_AllOff(_index);
|
|
|
|
if (offotherscroll)
|
|
{
|
|
if (!DSUtil.CheckNull(m_scrollview) && m_scrollview.Length > 0)
|
|
{
|
|
for (int i = 0; i < m_scrollview.Length; i++)
|
|
m_scrollview[i].gameObject.SetActive(false);
|
|
m_scrollview[_index].gameObject.SetActive(true);
|
|
}
|
|
else if (!DSUtil.CheckNull(m_content) && m_content.Length > 0)
|
|
{
|
|
for (int i = 0; i < m_content.Length; i++)
|
|
m_content[i].gameObject.SetActive(false);
|
|
m_content[_index].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < _lst.Count; i++)
|
|
MakeCard(_index, i).Set(_lst[i]);
|
|
}
|
|
} |