SideTabBar 기능 추가

This commit is contained in:
logonkhi
2025-09-25 19:58:30 +09:00
parent 68f6b343b3
commit 1aa64487d0
40 changed files with 600467 additions and 234 deletions

View File

@@ -5,26 +5,19 @@ using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UVC.Core;
using UVC.Extention;
using UVC.Factory;
using UVC.Factory.Component;
using UVC.Locale;
using UVC.UI.Commands;
using UVC.UI.Menu;
using UVC.UI.Modal;
namespace UVC.UI.List.ComponentList
{
/// <summary>
/// 컴포넌트 목록 UI를 관리하는 싱글톤 클래스입니다.
/// 컴포넌트 목록 UI를 관리하는 클래스입니다.
/// InfiniteScroll을 사용하여 대량의 데이터를 효율적으로 표시하고,
/// 검색 및 필터링 기능을 제공합니다.
/// IPointerEnterHandler, IPointerExitHandler를 구현하여
/// 마우스가 UI 영역에 있을 때 3D 뷰의 카메라 조작을 비활성화합니다.
/// </summary>
public class ComponentList : SingletonScene<ComponentList>, IPointerEnterHandler, IPointerExitHandler
public class ComponentList : MonoBehaviour
{
[Tooltip("데이터를 표시할 InfiniteScroll 컴포넌트입니다.")]
[SerializeField]
@@ -42,7 +35,7 @@ namespace UVC.UI.List.ComponentList
/// SingletonScene 초기화 과정에서 호출됩니다.
/// 필요한 컴포넌트를 찾고, 이벤트 리스너를 등록합니다.
/// </summary>
protected override void Init()
protected void Start()
{
// scrollList가 인스펙터에서 할당되지 않았을 경우, 자식에서 찾아봅니다.
if (scrollList == null)
@@ -67,12 +60,10 @@ namespace UVC.UI.List.ComponentList
//inputField.onEndEdit.AddListener(OnInputFieldChanged);
inputField.onSubmit.AddListener(OnInputFieldChanged);
}
gameObject.SetActive(false);
}
protected override void OnDestroy()
protected void OnDestroy()
{
if (inputField != null)
{
@@ -80,14 +71,13 @@ namespace UVC.UI.List.ComponentList
//inputField.onEndEdit.RemoveListener(OnInputFieldChanged);
inputField.onSubmit.RemoveListener(OnInputFieldChanged);
}
base.OnDestroy();
}
/// <summary>
/// FactoryObjectManager에서 데이터를 가져와 스크롤 리스트를 설정합니다.
/// 데이터를 카테고리별로 그룹화하고, 각 카테고리와 해당 항목들을 리스트에 추가합니다.
/// </summary>
public virtual void SetupData()
public virtual void SetupData(SortedDictionary<string, List<FactoryObjectInfo>> objectsData)
{
if (scrollList == null)
{
@@ -95,7 +85,7 @@ namespace UVC.UI.List.ComponentList
return;
}
if(inputField != null) inputField.text = string.Empty;
if (inputField != null) inputField.text = string.Empty;
//transform.SetAsFirstSibling();
scrollList.ClearData(); // 스크롤 리스트의 기존 데이터를 모두 비웁니다.
@@ -104,10 +94,10 @@ namespace UVC.UI.List.ComponentList
data = new List<ComponentListItemData>();
// 1. FactoryObjectManager에서 카테고리별로 그룹화된 객체 정보를 가져옵니다.
var infos = FactoryObjectManager.Instance.GetFactoryObjectInfosByCategory();
//var infos = FactoryObjectManager.Instance.GetFactoryObjectInfosByCategory();
// 2. 각 카테고리에 대해 루프를 돕니다.
foreach (var info in infos)
foreach (var info in objectsData)
{
// 2-1. 카테고리 아이템 데이터를 추가합니다.
data.Add(new ComponentListItemData
@@ -282,52 +272,15 @@ namespace UVC.UI.List.ComponentList
scrollList.InsertData(filteredData.ToArray(), true);
}
/// <summary>
/// 필터 버튼 클릭 시 호출됩니다.
/// 검색에 사용할 수 있는 특수 필터 키워드를 보여주는 컨텍스트 메뉴를 표시합니다.
/// </summary>
public virtual void OnClickFilter()
public void SetSearchText(string text)
{
Debug.Log("Filter button clicked.");
// 컨텍스트 메뉴에 표시할 항목들을 정의합니다.
var menuItems = new List<ContextMenuItemData>
if (inputField != null)
{
// "카테고리" 메뉴: 클릭 시 검색창에 "@Category "를 자동으로 입력해줍니다.
// 생성자: (itemId, displayName, command, commandParameter)
new ContextMenuItemData("Menu1", "카테고리", new ActionCommand(()=>{ if(inputField != null) { inputField.text = "@Category "; inputField.SetCaretToEndAsync().Forget();} })),
new ContextMenuItemData(isSeparator: true), // 구분선 추가
new ContextMenuItemData("Menu2", "구역", new ActionCommand(()=>{ if(inputField != null) { inputField.text = "@Area "; inputField.SetCaretToEndAsync().Forget();} })),
new ContextMenuItemData(isSeparator: true), // 구분선 추가
new ContextMenuItemData("Menu3", "층", new ActionCommand(()=>{ if(inputField != null) { inputField.text = "@Floor "; inputField.SetCaretToEndAsync().Forget(); } })),
};
// ContextMenuManager를 통해 마우스 위치에 메뉴를 표시합니다.
ContextMenuManager.Instance.ShowMenu(menuItems, Input.mousePosition);
}
/// <summary>
/// 새로고침 버튼 클릭 시 호출됩니다.
/// 리스트의 모든 데이터를 지우고 SetupData를 다시 호출하여 목록을 갱신합니다.
/// </summary>
public virtual void OnClickRefresh()
{
if (scrollList != null && data != null)
{
scrollList.Clear(); // 스크롤 리스트의 내용을 비웁니다.
SetupData(); // 데이터를 다시 설정합니다.
inputField.text = $"@{text} ";
inputField.SetCaretToEndAsync().Forget();
}
}
/// <summary>
/// 닫기 버튼 클릭 시 호출됩니다.
/// 컴포넌트 목록 UI를 비활성화하고, 카메라 컨트롤을 다시 활성화합니다.
/// </summary>
public virtual void OnClickClose()
{
gameObject.SetActive(false);
FactoryCameraController.Instance.Enable = true; // 카메라 컨트롤러 활성화
}
/// <summary>
/// 검색창의 'X' 버튼 클릭 시 호출됩니다.
@@ -356,22 +309,6 @@ namespace UVC.UI.List.ComponentList
}
}
/// <summary>
/// 마우스 포인터가 이 UI 요소의 영역 안으로 들어왔을 때 호출됩니다.
/// UI와 상호작용하는 동안 3D 뷰의 카메라가 움직이지 않도록 컨트롤러를 비활성화합니다.
/// </summary>
public virtual void OnPointerEnter(PointerEventData eventData)
{
FactoryCameraController.Instance.Enable = false; // 카메라 컨트롤러 비활성화
}
/// <summary>
/// 마우스 포인터가 이 UI 요소의 영역 밖으로 나갔을 때 호출됩니다.
/// 카메라 컨트롤을 다시 활성화하여 3D 뷰를 조작할 수 있도록 합니다.
/// </summary>
public virtual void OnPointerExit(PointerEventData eventData)
{
FactoryCameraController.Instance.Enable = true; // 카메라 컨트롤러 활성화
}
}
}