ComponentList 개발 중
This commit is contained in:
@@ -27,7 +27,7 @@ namespace UVC.UI.Menu
|
||||
/// `ICommand` 인터페이스를 구현하는 객체여야 합니다.
|
||||
/// 실행할 동작이 없는 경우 null일 수 있습니다.
|
||||
/// </summary>
|
||||
public ICommand Command { get; private set; }
|
||||
public ICommand? Command { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Command"/> 실행 시 전달될 파라미터입니다.
|
||||
@@ -35,12 +35,19 @@ namespace UVC.UI.Menu
|
||||
/// </summary>
|
||||
public object? CommandParameter { get; set; }
|
||||
|
||||
public ContextMenuItemData(string ItemId, string DisplayName, ICommand Command, string CommandParameter = null)
|
||||
/// <summary>
|
||||
/// 이 메뉴 아이템이 시각적인 구분선인지 여부를 나타냅니다.
|
||||
/// `true`이면 메뉴 UI에서 다른 아이템들과 구분되는 선으로 표시됩니다.
|
||||
/// </summary>
|
||||
public bool IsSeparator { get; private set; }
|
||||
|
||||
public ContextMenuItemData(string itemId = "", string displayName = "", ICommand? command = null, object? commandParameter = null, bool isSeparator = false)
|
||||
{
|
||||
this.ItemId = ItemId;
|
||||
this.DisplayName = DisplayName;
|
||||
this.Command = Command;
|
||||
this.CommandParameter = CommandParameter;
|
||||
this.ItemId = itemId;
|
||||
this.DisplayName = displayName;
|
||||
this.Command = command;
|
||||
this.CommandParameter = commandParameter;
|
||||
this.IsSeparator = isSeparator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace UVC.UI.Menu
|
||||
/// // 생성자: (itemId, displayName, command, commandParameter)
|
||||
/// new ContextMenuItemData("player_attack", "공격", new LogCommand(), "플레이어가 '공격'을 선택했습니다."),
|
||||
/// new ContextMenuItemData("player_talk", "대화", new LogCommand(), "플레이어가 '대화'를 선택했습니다."),
|
||||
/// new ContextMenuItemData(isSeparator: true), // 구분선 추가
|
||||
/// new ContextMenuItemData("player_inspect", "조사", new LogCommand(), "플레이어가 '조사'를 선택했습니다.")
|
||||
/// };
|
||||
///
|
||||
@@ -78,6 +79,10 @@ namespace UVC.UI.Menu
|
||||
[Tooltip("컨텍스트 메뉴의 각 항목으로 사용될 Button 프리팹입니다.")]
|
||||
private GameObject contextMenuItemPrefab;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("컨텍스트 메뉴의 구분선으로 사용될 UI 프리팹입니다.")]
|
||||
private GameObject contextMenuSeparatorPrefab;
|
||||
|
||||
[Header("캔버스 설정")]
|
||||
[SerializeField]
|
||||
[Tooltip("UI가 그려질 최상위 Canvas입니다. 메뉴가 다른 UI 위에 그려지도록 합니다.")]
|
||||
@@ -170,6 +175,16 @@ namespace UVC.UI.Menu
|
||||
{
|
||||
foreach (var itemData in items)
|
||||
{
|
||||
if (itemData.IsSeparator)
|
||||
{
|
||||
// 이 항목이 구분선인 경우, 구분선 프리팹을 인스턴스화합니다.
|
||||
if (contextMenuSeparatorPrefab != null)
|
||||
{
|
||||
Instantiate(contextMenuSeparatorPrefab, _activeMenuRect);
|
||||
}
|
||||
continue; // 다음 항목으로 넘어갑니다.
|
||||
}
|
||||
|
||||
// 풀에서 메뉴 항목 버튼을 가져옵니다.
|
||||
Button menuItemButton = _menuItemPool.GetItem(true, _activeMenuRect);
|
||||
|
||||
@@ -194,7 +209,7 @@ namespace UVC.UI.Menu
|
||||
{
|
||||
// 항목을 클릭하면 메뉴를 닫고, 설정된 액션을 실행합니다.
|
||||
HideMenu();
|
||||
itemData.Command.Execute(itemData.CommandParameter);
|
||||
itemData.Command?.Execute(itemData.CommandParameter);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -28,19 +28,19 @@ namespace UVC.UI.Menu
|
||||
/// `ICommand` 인터페이스를 구현하는 객체여야 합니다.
|
||||
/// 실행할 동작이 없는 경우 null일 수 있습니다.
|
||||
/// </summary>
|
||||
public ICommand Command { get; private set; }
|
||||
public ICommand? Command { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Command"/> 실행 시 전달될 파라미터입니다.
|
||||
/// 이 파라미터는 <see cref="TopMenuController.HandleMenuItemClicked"/>에서 <see cref="ICommand.Execute"/> 호출 시 사용될 수 있습니다.
|
||||
/// </summary>
|
||||
public object CommandParameter { get; set; }
|
||||
public object? CommandParameter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 이 메뉴 아이템에 속한 하위 메뉴 아이템들의 목록입니다.
|
||||
/// 하위 메뉴가 없는 경우 빈 리스트입니다.
|
||||
/// </summary>
|
||||
public List<MenuItemData> SubMenuItems { get; private set; }
|
||||
public List<MenuItemData>? SubMenuItems { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 이 메뉴 아이템이 시각적인 구분선인지 여부를 나타냅니다.
|
||||
@@ -85,7 +85,7 @@ namespace UVC.UI.Menu
|
||||
/// <param name="subMenuItems">하위 메뉴 아이템 목록 (선택 사항).</param>
|
||||
/// <param name="isSeparator">구분선 여부 (선택 사항, 기본값: false).</param>
|
||||
/// <param name="isEnabled">활성화 상태 (선택 사항, 기본값: true).</param>
|
||||
public MenuItemData(string itemId, string displayName, ICommand command = null, object commandParameter = null, List<MenuItemData> subMenuItems = null, bool isSeparator = false, bool isEnabled = true, int depth = 0)
|
||||
public MenuItemData(string itemId, string displayName, ICommand? command = null, object? commandParameter = null, List<MenuItemData>? subMenuItems = null, bool isSeparator = false, bool isEnabled = true, int depth = 0)
|
||||
{
|
||||
ItemId = itemId;
|
||||
DisplayName = displayName;
|
||||
|
||||
Reference in New Issue
Block a user