ComponentList 완료, Context 메뉴 추가

This commit is contained in:
김형인
2025-08-09 01:39:24 +09:00
parent 165c3a709f
commit bf10b6f94a
22 changed files with 1428 additions and 42 deletions

View File

@@ -3,11 +3,14 @@ using Gpm.Ui;
using System;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UVC.Core;
using UVC.Factory.Component;
using UVC.UI.Commands;
using UVC.UI.Menu;
using UVC.UI.Modal;
using static UnityEngine.Rendering.DebugUI;
@@ -44,8 +47,8 @@ namespace UVC.Factory.Modal.ComponentList
}
inputField.onEndEdit.AddListener(OnInputFieldChanged);
//inputField.onSubmit.AddListener(OnInputFieldChanged);
//inputField.onEndEdit.AddListener(OnInputFieldChanged);
inputField.onSubmit.AddListener(OnInputFieldChanged);
gameObject.SetActive(false);
}
@@ -54,8 +57,8 @@ namespace UVC.Factory.Modal.ComponentList
{
if (inputField != null)
{
inputField.onEndEdit.RemoveListener(OnInputFieldChanged);
//inputField.onSubmit.RemoveListener(OnInputFieldChanged);
//inputField.onEndEdit.RemoveListener(OnInputFieldChanged);
inputField.onSubmit.RemoveListener(OnInputFieldChanged);
}
base.OnDestroy();
}
@@ -71,17 +74,15 @@ namespace UVC.Factory.Modal.ComponentList
Toast.Show("검색어는 3글자 이상 입력해주세요.", 2f);
return;
}
Debug.Log($"Input field changed: {text}");
Predicate<InfiniteScrollData> func = (data) =>
{
if (data is ComponentListItemData itemData)
{
Debug.Log($"Filtering isCategory:{itemData.isCategory}, Contains:{itemData.generalName.Contains(text)}");
return !itemData.isCategory && itemData.generalName.Contains(text);
//원하는 조건일때 false를 반환해야 됨
return !(!itemData.isCategory && itemData.generalName.Contains(text));
}
return false;
return true;
};
scrollList.SetFilter(func);
@@ -95,7 +96,7 @@ namespace UVC.Factory.Modal.ComponentList
return;
}
transform.SetAsFirstSibling();
//transform.SetAsFirstSibling();
data?.Clear();
@@ -126,9 +127,22 @@ namespace UVC.Factory.Modal.ComponentList
scrollList.InsertData(data.ToArray());
}
public void OnClickFilter()
{
Debug.Log("Filter button clicked.");
var menuItems = new List<ContextMenuItemData>
{
// ContextMenuItemData 생성자를 사용하여 각 메뉴 항목을 정의합니다.
// 생성자: (itemId, displayName, command, commandParameter)
new ContextMenuItemData("Menu1", "Menu1", new DebugLogCommand("Menu1 click")),
new ContextMenuItemData("Menu2", "Menu2", new DebugLogCommand("Menu2 click")),
new ContextMenuItemData("Menu3", "Menu3", new DebugLogCommand("Menu3 click"))
};
// 5. ContextMenuManager 싱글톤 인스턴스를 통해 메뉴를 표시합니다.
ContextMenuManager.Instance.ShowMenu(menuItems, Input.mousePosition);
}
@@ -144,6 +158,17 @@ namespace UVC.Factory.Modal.ComponentList
public void OnClickClose()
{
gameObject.SetActive(false);
FactoryCameraController.Instance.Enable = true; // 카메라 컨트롤러 활성화
}
public void OnClickClearText()
{
if (inputField != null)
{
inputField.text = string.Empty; // 입력 필드 초기화
inputField.ActivateInputField(); // 입력 필드에 다시 포커스 설정
if(scrollList != null) scrollList.SetFilter(null);
}
}
public void OnPointerEnter(PointerEventData eventData)

View File

@@ -137,6 +137,11 @@ namespace UVC.Factory.Modal.ComponentList
if (itemData.factoryObjectInfo != null)
{
FactoryObject? obj = FactoryObjectManager.Instance.FindById(itemData.factoryObjectInfo.Id);
if(obj == null)
{
Toast.Show($"{itemData.factoryObjectInfo.Name} 객체를 찾을 수 없습니다.", 2f);
return;
}
if (obj != null && obj.gameObject.activeSelf)
{
//객체로 이동