accorionWindow 추가, libraryWindow 추가
This commit is contained in:
@@ -6,63 +6,30 @@ using UVC.UI.List.Accordion;
|
||||
|
||||
namespace UVC.UI.Window
|
||||
{
|
||||
/// <summary>
|
||||
/// 아코디언 리스트(<see cref="AccordionList"/>)를 포함하는 간단한 컨테이너 윈도우.
|
||||
/// 외부에서 전달된 데이터로 내부 리스트를 구성합니다.
|
||||
/// </summary>
|
||||
public class AccordionWindow : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private RectTransform root = default!;
|
||||
[SerializeField] private AccordionList? accordionListPrefab = null;
|
||||
private AccordionList? _instance;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
EnsureRoot();
|
||||
EnsureInstance();
|
||||
}
|
||||
[SerializeField]
|
||||
private AccordionList list = default!;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
EnsureRoot();
|
||||
EnsureInstance();
|
||||
}
|
||||
|
||||
private void EnsureRoot()
|
||||
{
|
||||
if (root == null)
|
||||
if (list == null)
|
||||
{
|
||||
var go = new GameObject("AccordionRoot", typeof(RectTransform));
|
||||
go.transform.SetParent(transform, false);
|
||||
root = (RectTransform)go.transform;
|
||||
var v = go.AddComponent<VerticalLayoutGroup>();
|
||||
v.childControlHeight = true;
|
||||
v.childForceExpandHeight = false;
|
||||
v.spacing = 0f;
|
||||
var fitter = go.AddComponent<ContentSizeFitter>();
|
||||
fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
if (accordionListPrefab != null)
|
||||
{
|
||||
_instance = Instantiate(accordionListPrefab, root);
|
||||
_instance.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
var go = new GameObject("AccordionList", typeof(RectTransform), typeof(AccordionList));
|
||||
go.transform.SetParent(root, false);
|
||||
_instance = go.GetComponent<AccordionList>();
|
||||
}
|
||||
Debug.LogWarning("AccordionWindow: list is not assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 내부 <see cref="AccordionList"/>에 데이터를 설정합니다.
|
||||
/// </summary>
|
||||
/// <param name="data">아코디언 루트 데이터.</param>
|
||||
public void SetData(AccordionData data)
|
||||
{
|
||||
EnsureRoot();
|
||||
EnsureInstance();
|
||||
_instance!.SetData(data);
|
||||
list!.SetData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
43
Assets/Scripts/UVC/UI/Window/LibraryWindow.cs
Normal file
43
Assets/Scripts/UVC/UI/Window/LibraryWindow.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UVC.UI.List;
|
||||
|
||||
namespace UVC.UI.Window
|
||||
{
|
||||
public class LibraryWindow : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private PrefabGrid prefabGrid;
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
if (prefabGrid == null)
|
||||
{
|
||||
prefabGrid = GetComponentInChildren<PrefabGrid>();
|
||||
}
|
||||
|
||||
if (prefabGrid == null)
|
||||
{
|
||||
Debug.LogError("InfiniteScroll component is not assigned or found in Children.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetData(List<PrefabGridItemData> list)
|
||||
{
|
||||
|
||||
prefabGrid?.SetupData(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 닫기
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UVC/UI/Window/LibraryWindow.cs.meta
Normal file
2
Assets/Scripts/UVC/UI/Window/LibraryWindow.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 966dc2f3a492248468ab25267731e1d0
|
||||
Reference in New Issue
Block a user