menu 개발 중. 언어 변경 시 반영 않됨
This commit is contained in:
8
Assets/Scripts/SampleProject/UI/Commands.meta
Normal file
8
Assets/Scripts/SampleProject/UI/Commands.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fed6356fdb3cc64fb80df74a7f5cb63
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/SampleProject/UI/Menu.meta
Normal file
8
Assets/Scripts/SampleProject/UI/Menu.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1081f5b4e1f974e4593750f8fa2d9697
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,131 @@
|
||||
using UVC.UI.Menu;
|
||||
using System.Collections.Generic;
|
||||
using UVC.UI.Commands; // DebugLogCommand 등 기본 Command 사용 시
|
||||
// using SampleProject.UI.Commands; // 프로젝트별 Command 사용 시
|
||||
using UVC.Log; // 필요에 따라 UVC.Log 또는 프로젝트별 로깅 시스템 사용
|
||||
using System;
|
||||
|
||||
namespace SampleProject.UI.Menu
|
||||
{
|
||||
public class SampleProjectTopMenuController : TopMenuController
|
||||
{
|
||||
protected override void Awake()
|
||||
{
|
||||
// 1. 동일한 GameObject에서 SampleProjectTopMenuView 컴포넌트 검색
|
||||
view = GetComponent<SampleProjectTopMenuView>();
|
||||
|
||||
// 2. 동일한 GameObject에 없다면, 자식 GameObject에서 검색
|
||||
if (view == null)
|
||||
{
|
||||
view = GetComponentInChildren<SampleProjectTopMenuView>();
|
||||
}
|
||||
|
||||
// view가 여전히 null이라면, 부모 타입(TopMenuView)으로 다시 한번 검색 (선택 사항)
|
||||
if (view == null)
|
||||
{
|
||||
ULog.Warning("SampleProjectTopMenuView를 찾을 수 없어 TopMenuView로 검색합니다.");
|
||||
base.Awake(); // 부모의 Awake를 호출하여 TopMenuView를 찾도록 시도
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
// model과 _locManager는 부모 클래스에서 protected로 선언되어 접근 가능
|
||||
// 만약 부모의 Start 로직을 완전히 대체하고 싶지 않다면 base.Start()를 호출할 수 있습니다.
|
||||
// 여기서는 메뉴 아이템 구성을 완전히 새로 하므로 base.Start()를 호출하지 않거나,
|
||||
// 호출 후 model.MenuItems.Clear()를 다시 수행합니다.
|
||||
|
||||
model = new TopMenuModel(); // 새 모델 인스턴스 또는 프로젝트별 모델 사용
|
||||
_locManager = UVC.Locale.LocalizationManager.Instance; // LocalizationManager 인스턴스 가져오기
|
||||
|
||||
if (view == null)
|
||||
{
|
||||
ULog.Error("SampleProjectTopMenuView가 Inspector에서 할당되지 않았거나 찾을 수 없습니다.");
|
||||
return;
|
||||
}
|
||||
if (_locManager == null)
|
||||
{
|
||||
ULog.Error("LocalizationManager 인스턴스를 찾을 수 없습니다. 메뉴 텍스트가 올바르게 표시되지 않을 수 있습니다.");
|
||||
}
|
||||
|
||||
InitializeMenuItems(); // 프로젝트별 메뉴 아이템 초기화 메서드 호출
|
||||
|
||||
view.ClearMenuItems();
|
||||
view.CreateMenuItems(model.MenuItems, view.MenuContainer);
|
||||
|
||||
view.OnMenuItemClicked += HandleMenuItemClicked; // 부모의 핸들러 재사용 또는 override
|
||||
if (_locManager != null)
|
||||
{
|
||||
_locManager.OnLanguageChanged += HandleLanguageChanged; // 부모의 핸들러 재사용 또는 override
|
||||
}
|
||||
ULog.Debug("SampleProjectTopMenuController Start 실행됨");
|
||||
}
|
||||
|
||||
// 부모의 OnDestroy를 그대로 사용하거나, 필요시 override하여 로직 추가/변경
|
||||
// protected new void OnDestroy()
|
||||
// {
|
||||
// base.OnDestroy();
|
||||
// // 프로젝트별 리소스 해제 로직 추가
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// 프로젝트에 특화된 메뉴 아이템들을 초기화합니다.
|
||||
/// TopMenuController의 InitializeMenuItems를 override하거나,
|
||||
/// 이처럼 새로운 메서드를 만들어 사용할 수 있습니다.
|
||||
/// </summary>
|
||||
protected override void InitializeMenuItems()
|
||||
{
|
||||
model.MenuItems.Clear(); // 기존 메뉴 아이템 제거
|
||||
|
||||
// 예시: "파일" 메뉴는 유지하되, "새 프로젝트" 제거 및 "프로젝트 설정" 추가
|
||||
model.MenuItems.Add(new MenuItemData("file", "menu_file", subMenuItems: new List<MenuItemData>
|
||||
{
|
||||
new MenuItemData("file_new_file", "menu_file_new_file", new DebugLogCommand("[SampleProject] 새 파일 선택됨")),
|
||||
new MenuItemData("file_open", "menu_file_open", new DebugLogCommand("[SampleProject] 파일 열기 선택됨")),
|
||||
MenuItemData.CreateSeparator("file_sep_sample1"),
|
||||
new MenuItemData("project_settings", "project_settings_key", new DebugLogCommand("[SampleProject] 프로젝트 설정 선택됨")), // 프로젝트별 메뉴 아이템
|
||||
MenuItemData.CreateSeparator("file_sep_sample2"),
|
||||
new MenuItemData("file_exit", "menu_file_exit", new QuitApplicationCommand())
|
||||
}));
|
||||
|
||||
// "편집" 메뉴는 그대로 사용 (부모 클래스의 메뉴 아이템 구성을 재활용하거나 여기서 다시 정의)
|
||||
model.MenuItems.Add(new MenuItemData("edit", "menu_edit", subMenuItems: new List<MenuItemData>
|
||||
{
|
||||
new MenuItemData("edit_undo", "menu_edit_undo", new DebugLogCommand("[SampleProject] 실행 취소 선택됨")),
|
||||
new MenuItemData("edit_redo", "menu_edit_redo", new DebugLogCommand("[SampleProject] 다시 실행 선택됨"))
|
||||
}));
|
||||
|
||||
// "도움말" 메뉴 추가 (프로젝트별)
|
||||
model.MenuItems.Add(new MenuItemData("help", "menu_help_key", subMenuItems: new List<MenuItemData>
|
||||
{
|
||||
new MenuItemData("help_about", "menu_about_key", new DebugLogCommand("[SampleProject] 프로그램 정보 선택됨"))
|
||||
}));
|
||||
|
||||
|
||||
if (_locManager != null)
|
||||
{
|
||||
// 언어 메뉴는 부모와 동일하게 유지하거나, 프로젝트별로 변경 가능
|
||||
model.MenuItems.Add(new MenuItemData("language", "menu_language", subMenuItems: new List<MenuItemData>
|
||||
{
|
||||
new MenuItemData("lang_ko", "menu_lang_korean", new ChangeLanguageCommand("ko-KR", _locManager)),
|
||||
new MenuItemData("lang_en", "menu_lang_english", new ChangeLanguageCommand("en-US", _locManager)),
|
||||
// new MenuItemData("lang_jp", "menu_lang_japanese", new ChangeLanguageCommand("ja-JP", _locManager)) // 예: 일본어 추가
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
ULog.Warning("[SampleProject] LocalizationManager가 null이므로 언어 변경 메뉴를 초기화할 수 없습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
// HandleMenuItemClicked와 HandleLanguageChanged는 필요에 따라 override하여
|
||||
// 프로젝트별 특별한 처리를 추가할 수 있습니다.
|
||||
// 예시:
|
||||
// protected override void HandleMenuItemClicked(MenuItemData clickedItemData)
|
||||
// {
|
||||
// base.HandleMenuItemClicked(clickedItemData); // 부모 로직 실행
|
||||
// ULog.Debug($"[SampleProject] 메뉴 아이템 클릭됨: {clickedItemData.ItemId}");
|
||||
// // 프로젝트별 추가 클릭 처리 로직
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7feda6d8859e41440902b86bd6018a8a
|
||||
@@ -0,0 +1,57 @@
|
||||
using UVC.UI.Menu;
|
||||
using UnityEngine;
|
||||
using UVC.Log; // 필요에 따라 UVC.Log 또는 프로젝트별 로깅 시스템 사용
|
||||
|
||||
namespace SampleProject.UI.Menu
|
||||
{
|
||||
public class SampleProjectTopMenuView : TopMenuView
|
||||
{
|
||||
// 프로젝트별 MenuItem 프리팹 경로 (덮어쓰기 예시)
|
||||
// private new const string MenuItemPrefabPath = "Prefabs/SampleProject/UI/Menu/SampleMenuItem";
|
||||
// 프로젝트별 MenuSeparator 프리팹 경로 (덮어쓰기 예시)
|
||||
// private new const string MenuSeparatorPrefabPath = "Prefabs/SampleProject/UI/Menu/SampleMenuSeparator";
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake(); // 부모 클래스의 Awake 로직 실행
|
||||
|
||||
// 여기에 SampleProjectTopMenuView만의 초기화 로직 추가
|
||||
// 예: 프로젝트별 프리팹 경로를 사용하도록 설정 변경
|
||||
// if (!string.IsNullOrEmpty(MenuItemPrefabPath))
|
||||
// {
|
||||
// menuItemPrefab = Resources.Load<GameObject>(MenuItemPrefabPath);
|
||||
// if (menuItemPrefab == null)
|
||||
// {
|
||||
// ULog.Error($"[SampleProject] 메뉴 아이템 프리팹을 Resources 폴더에서 로드할 수 없습니다. 경로: {MenuItemPrefabPath}");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!string.IsNullOrEmpty(MenuSeparatorPrefabPath))
|
||||
// {
|
||||
// menuSeparatorPrefab = Resources.Load<GameObject>(MenuSeparatorPrefabPath);
|
||||
// if (menuSeparatorPrefab == null)
|
||||
// {
|
||||
// ULog.Error($"[SampleProject] 메뉴 구분선 프리팹을 Resources 폴더에서 로드할 수 없습니다. 경로: {MenuSeparatorPrefabPath}");
|
||||
// }
|
||||
// }
|
||||
|
||||
// 예: 프로젝트별 메뉴 아이템 크기 및 간격 변경
|
||||
// menuItemWidth = 120;
|
||||
// menuItemHeight = 35;
|
||||
// menuItemHorizontalGap = 5;
|
||||
ULog.Debug("SampleProjectTopMenuView Awake 실행됨");
|
||||
}
|
||||
|
||||
// 필요하다면 CreateMenuItems, LayoutMenuItem 등의 메서드를 override하여
|
||||
// 프로젝트에 특화된 메뉴 생성 및 레이아웃 로직을 구현할 수 있습니다.
|
||||
// 예시:
|
||||
// public override Vector2 CreateMenuItems(List<MenuItemData> items, Transform parentContainer, int depth = 0)
|
||||
// {
|
||||
// ULog.Debug("SampleProjectTopMenuView CreateMenuItems 실행됨");
|
||||
// // 프로젝트별 추가 로직...
|
||||
// return base.CreateMenuItems(items, parentContainer, depth);
|
||||
// }
|
||||
|
||||
// 프로젝트별로 특정 UI 요소의 동작을 변경하거나 추가할 수 있습니다.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 292c6e1db0e89c9488a72423d84bd969
|
||||
Reference in New Issue
Block a user