draggableList/Tab 개발 중
This commit is contained in:
75
Assets/Scripts/UVC/Factory/Modal/ConfigDataOrderModal.cs
Normal file
75
Assets/Scripts/UVC/Factory/Modal/ConfigDataOrderModal.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
#nullable enable
|
||||
using UnityEngine;
|
||||
using UVC.UI.List;
|
||||
|
||||
namespace UVC.Factory.Modal
|
||||
{
|
||||
public class ConfigDataOrderModal : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private DraggableScrollList? draggableList;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
if (draggableList == null)
|
||||
{
|
||||
Debug.LogError("draggableList 참조가 설정되지 않았습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 이벤트 구독
|
||||
draggableList.OnItemReordered += OnItemReordered;
|
||||
draggableList.OnItemSelected += OnItemSelected;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 1. DraggableItemData 설정
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
draggableList?.AddItem(new DraggableItemData($"Item {i + 1}", i));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 아이템 순서 변경 이벤트 처리
|
||||
/// </summary>
|
||||
/// <param name = "sender" > 이벤트 발생자</param>
|
||||
/// <param name = "e" > 이벤트 인자</param>
|
||||
private void OnItemReordered(object? sender, DraggableItemReorderEventArgs e)
|
||||
{
|
||||
Debug.Log($"아이템 순서 변경됨: ID={e.ItemId}, {e.OldIndex} -> {e.NewIndex}");
|
||||
|
||||
// 여기에 순서 변경에 대한 비즈니스 로직 구현
|
||||
// 예: 서버에 변경사항 전송, 설정 저장 등
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 아이템 선택 이벤트 처리
|
||||
/// </summary>
|
||||
/// <param name="sender">이벤트 발생자</param>
|
||||
/// <param name="item">선택된 아이템</param>
|
||||
private void OnItemSelected(object? sender, DraggableListItem item)
|
||||
{
|
||||
if (item?.Data != null)
|
||||
{
|
||||
Debug.Log($"아이템 선택됨: {item.Data.Id}");
|
||||
|
||||
// 선택된 아이템에 대한 처리
|
||||
// 예: 상세 정보 표시, 편집 모드 진입 등
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 컴포넌트 정리
|
||||
/// </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (draggableList != null)
|
||||
{
|
||||
draggableList.OnItemReordered -= OnItemReordered;
|
||||
draggableList.OnItemSelected -= OnItemSelected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc92cc933c1ce844c955ffc32982d3af
|
||||
Reference in New Issue
Block a user