using NUnit.Framework; using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Studio.UVC.UI { public class UVCScrollView : MonoBehaviour { private ScrollRect scrollRect; private UVCScrollviewItem item; private Action onClickScrollItem; private List scrollItems = new(); public void Init(Vector2 size) { scrollRect = GetComponent(); var rect = GetComponent(); rect.sizeDelta = size; item = Resources.Load("Prefabs/Common/UVCScrollviewItem"); } public void SetVerticalItem(List items) { if (!scrollRect.gameObject.TryGetComponent(out var layout)) { layout.gameObject.AddComponent(); } } public void SetHorizontalItem(List items) { if (!scrollRect.gameObject.TryGetComponent(out var layout)) { layout.gameObject.AddComponent(); } } public void SetLayOutGroupItem(Listitems,Vector2 cellSize) { if(!scrollRect.gameObject.TryGetComponent(out var layout)) { layout.gameObject.AddComponent(); layout.cellSize = cellSize; } foreach (T item in items) { var itme = CreateItem(); } } public UVCScrollviewItem CreateItem() { var resultItem = Instantiate(item, scrollRect.content); resultItem.onClickButton?.Invoke(); scrollItems.Add(resultItem); return resultItem; } } }