48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Studio.UVC.UI
|
|
{
|
|
public class UISubAccordion<T> : UIAccordion<T> where T : MonoBehaviour
|
|
{
|
|
|
|
public static string subPrefabsPath = "Prefabs/Dashboard/UISubAccordion";
|
|
|
|
private Dictionary<int, T> predictionItemTables = new();
|
|
private float space = 5f;
|
|
|
|
public Action onExpandYSize;
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
}
|
|
|
|
public void SetSubItem(string titleKey, List<T> items = null)
|
|
{
|
|
this.titletKey = titleKey;
|
|
var upSize = 0f;
|
|
foreach (var item in items)
|
|
{
|
|
item.transform.SetParent(transform);
|
|
var rect = item.GetComponent<RectTransform>();
|
|
if (upSize < rect.sizeDelta.y)
|
|
upSize = rect.sizeDelta.y;
|
|
}
|
|
|
|
ExpandYSizeBarList(upSize);
|
|
}
|
|
|
|
private void ExpandYSizeBarList(float upSize)
|
|
{
|
|
if (predictionItemTables.Count == 0)
|
|
return;
|
|
|
|
BarList.sizeDelta = new Vector2(BarList.sizeDelta.x, (predictionItemTables.Count * upSize) + (predictionItemTables.Count - 1) * space);
|
|
rect.sizeDelta = new Vector2(rect.sizeDelta.x, BarList.sizeDelta.y + HeadLine.sizeDelta.y + 8f); // 해더 타이틀 사이즈 + space size + BarList Size;
|
|
yFullSize = rect.sizeDelta.y;
|
|
onExpandYSize?.Invoke();
|
|
}
|
|
}
|
|
}
|