Files
XRLib/Assets/Scripts/UVC/UI/ToolBar/View/ToolbarExpandableButtonViewProcessor.cs

51 lines
2.2 KiB
C#
Raw Normal View History

2025-06-18 00:16:49 +09:00
using UnityEngine;
using UnityEngine.UI;
using UVC.UI.Toolbar.Model;
using UVC.UI.ToolBar.View;
namespace UVC.UI.Toolbar.View
{
public class ToolbarExpandableButtonViewProcessor : IButtonViewProcessor
{
public GameObject CreateButtonUI(ToolbarButtonBase buttonModel, Transform parentContainer, ToolbarView viewContext)
{
if (viewContext.expandableButtonPrefab == null)
{
Debug.LogError("ExpandableButtonViewProcessor: expandableButtonPrefab이 ToolbarView에 할당되지 않았습니다.", viewContext);
return null;
}
return Object.Instantiate(viewContext.expandableButtonPrefab, parentContainer);
}
public void SetupButtonInteractions(ToolbarButtonBase buttonModel, GameObject buttonUIObject, ToolbarView viewContext)
{
ToolbarExpandableButton expandableModel = buttonModel as ToolbarExpandableButton;
if (expandableModel == null) return;
Button uiButton = buttonUIObject.GetComponent<Button>();
if (uiButton != null)
{
uiButton.onClick.AddListener(() =>
{
expandableModel.ExecuteClick();
viewContext.ToggleSubMenu(expandableModel, buttonUIObject);
});
}
else
{
Debug.LogError($"ExpandableButtonViewProcessor: ExpandableButton '{expandableModel.Text}'의 GameObject에 Button 컴포넌트가 없습니다.", buttonUIObject);
}
UpdateCommonButtonVisuals(buttonModel, buttonUIObject, viewContext);
}
public void UpdateCommonButtonVisuals(ToolbarButtonBase buttonModel, GameObject buttonUIObject, ToolbarView viewContext)
{
viewContext.InternalUpdateCommonButtonVisuals(buttonModel, buttonUIObject);
}
public void UpdateToggleStateVisuals(ToolbarToggleButton toggleButtonModel, GameObject buttonUIObject, bool isSelected, ToolbarView viewContext)
{
// 확장 버튼은 기본 토글 상태가 없음 (하위 메뉴 표시 여부는 다른 메커니즘으로 관리)
}
}
}