123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BaseList : MonoBehaviour
- {
- [HideInInspector]
- public int rCount = 0;
- [HideInInspector]
- public List<BaseConfig> configs = new List<BaseConfig>();
- [HideInInspector]
- public List<BaseView> Views = new List<BaseView>();
- [HideInInspector]
- private int maxCount;
- [HideInInspector]
- public int maxRowItemCount = 0;
- [HideInInspector]
- public int maxColumItemCount = 0;
- public int Row;
- public int Column;
- // Start is called before the first frame update
- void Start()
- {
- }
- public virtual void initList(List<BaseConfig> c)
- {
- if (Views.Count<=0)
- {
- maxCount = Row * Column;
- Views = new List<BaseView>();
- BaseView view = this.GetComponentInChildren<BaseView>();
- // Debug.Log("viewviewviewview");
- view.gameObject.SetActive(false);
- Views.Add(view);
- BaseView cloneView;
- for (int i = 0; i < maxCount - 1; i++)
- {
- cloneView = Instantiate(view);
- cloneView.transform.parent = this.transform;
- cloneView.name = view.name + "_" + (i + 1);
- cloneView.transform.localScale = view.transform.localScale;
- cloneView.transform.localRotation = view.transform.localRotation;
- Views.Add(cloneView);
- }
- }
- configs = new List<BaseConfig>();
- c.ForEach(i => configs.Add(i));
- int vindex=0;
- for (int i = 0; i < Views.Count; i++)
- {
- if(i< configs.Count)
- {
- Views[i].init(i, configs[i], vindex);
- Views[i].baselist = this;
- Views[i].gameObject.SetActive(true);
- vindex++;
- //Debug.Log(i);
- //if (i == 1)
- //{
- // AgoraVideoAudioManager.Instance.ShowOneView(RoomMain.Instance.agoraRawImage);
- //}
- }
- else
- {
- Views[i].gameObject.SetActive(false);
- }
- }
- maxRowItemCount = (this.configs.Count - 1) / Row + 1;
- maxColumItemCount = (this.configs.Count - 1) / Column + 1;
- // rCount = maxItemCount;
- }
- public void showItems(int start,int end,bool isShow=false)
- {
- int vindex = 0;
- for (int i = 0; i < Views.Count; i++)
- {
- Views[i].sx = i;
- if ((i + start) < configs.Count&&i<= (end - start)&& (i + start)>=0)
- {
- if (Views[i].Index!= (i + start))
- {
- Views[i].init((i + start),configs[(i + start)], vindex);
- Views[i].baselist = this;
- }
- if (Views[i].isShow|| isShow)
- {
- Views[i].gameObject.SetActive(true);
- vindex++;
- }
- }
- else
- {
- Views[i].gameObject.SetActive(false);
- }
- }
- }
- public void showItems(List<int> items)
- {
- int vindex = 0;
- for (int i = 0; i < items.Count; i++)
- {
- if(items[i]>=0)
- {
- if(configs.Count>items[i])
- {
- if (Views[i].Index != items[i])
- {
- Views[i].init(items[i], configs[items[i]], vindex);
- Views[i].baselist = this;
- }
- Views[i].gameObject.SetActive(true);
- vindex++;
- }
- else
- {
- Views[i].gameObject.SetActive(false);
- }
- }
- else
- {
- Views[i].gameObject.SetActive(false);
- }
- }
- }
- public virtual void updateConfig(List<BaseConfig> configs)
- {
- // this.configs = configs;
- initList(configs);
- }
- }
|