12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using SUIFW;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BaseList : MonoBehaviour
- {
- [HideInInspector]
- public List<BaseConfig> configs = new List<BaseConfig>();
- [HideInInspector]
- public List<BaseView> Views = new List<BaseView>();
- [HideInInspector]
- private int maxCount;
- public virtual void InitList(List<BaseConfig> c)
- {
- if (Views.Count <= 0)
- {
- maxCount = 10;
- Views = new List<BaseView>();
- BaseView cloneView;
- for (int i = 0; i < maxCount; i++)
- {
- GameObject peerItemObj = ResourcesMgr.GetInstance().LoadAsset("ItemPrefabs/PeerItem", false);
- peerItemObj.transform.SetParent(this.transform);
- peerItemObj.transform.localScale = new Vector3(1, 1, 1);
- cloneView = peerItemObj.GetComponent<BaseView>();
- 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++;
- }
- else
- {
- Views[i].gameObject.SetActive(false);
- }
- }
- }
- }
|