UTKToolBar 개발 완료
This commit is contained in:
@@ -13,13 +13,13 @@ namespace Sample
|
||||
/// <para><b>[ 특징 ]</b></para>
|
||||
/// <list type="bullet">
|
||||
/// <item><description>프리팹 없이 런타임에 새 GameObject가 자동 생성됨</description></item>
|
||||
/// <item><description>Injector가 new GameObject().AddComponent<T>()로 생성</description></item>
|
||||
/// <item><description>Injector가 new GameObject().AddComponent<T>()로 생성</description></item>
|
||||
/// <item><description>App 라이프사이클이면 DontDestroyOnLoad 자동 적용</description></item>
|
||||
/// <item><description>다른 서비스([Inject] ILogService)에 대한 의존성 주입 지원</description></item>
|
||||
/// </list>
|
||||
///
|
||||
/// <para><b>[ 등록 방법 ]</b></para>
|
||||
/// <code>Injector.Register<IAudioManager, InjectorSampleAudioManager>(ServiceLifetime.App);</code>
|
||||
/// <code>Injector.Register<IAudioManager, InjectorSampleAudioManager>(ServiceLifetime.App);</code>
|
||||
///
|
||||
/// <para><b>[ 사용 방법 ]</b></para>
|
||||
/// <code>
|
||||
@@ -41,8 +41,8 @@ namespace Sample
|
||||
///
|
||||
/// private void Awake()
|
||||
/// {
|
||||
/// bgmSource = gameObject.AddComponent<AudioSource>();
|
||||
/// sfxSource = gameObject.AddComponent<AudioSource>();
|
||||
/// bgmSource = gameObject.AddComponent<AudioSource>();
|
||||
/// sfxSource = gameObject.AddComponent<AudioSource>();
|
||||
/// bgmSource.loop = true;
|
||||
/// }
|
||||
/// </code>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Sample
|
||||
/// Type D 예시: MonoBehaviour SingletonApp - 네트워크 관리자
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><b>[ 타입 ]</b> Type D - MonoBehaviour SingletonApp (SingletonApp<T> 상속)</para>
|
||||
/// <para><b>[ 타입 ]</b> Type D - MonoBehaviour SingletonApp (SingletonApp<T> 상속)</para>
|
||||
/// <para><b>[ 라이프사이클 ]</b> App - 씬 전환 시에도 유지 (DontDestroyOnLoad)</para>
|
||||
///
|
||||
/// <para><b>[ 특징 ]</b></para>
|
||||
@@ -19,7 +19,7 @@ namespace Sample
|
||||
/// </list>
|
||||
///
|
||||
/// <para><b>[ 등록 방법 ]</b></para>
|
||||
/// <code>Injector.RegisterSingleton<InjectorSampleNetworkManager>();</code>
|
||||
/// <code>Injector.RegisterSingleton<InjectorSampleNetworkManager>();</code>
|
||||
///
|
||||
/// <para><b>[ 씬 설정 (선택) ]</b></para>
|
||||
/// <list type="number">
|
||||
@@ -40,8 +40,8 @@ namespace Sample
|
||||
///
|
||||
/// <para><b>[ InjectorSampleSettingsManager와의 차이점 ]</b></para>
|
||||
/// <list type="table">
|
||||
/// <item><term>SettingsManager</term><description>Singleton<T> - 순수 C#, GameObject 없음</description></item>
|
||||
/// <item><term>NetworkManager</term><description>SingletonApp<T> - MonoBehaviour, GameObject 필요</description></item>
|
||||
/// <item><term>SettingsManager</term><description>Singleton<T> - 순수 C#, GameObject 없음</description></item>
|
||||
/// <item><term>NetworkManager</term><description>SingletonApp<T> - MonoBehaviour, GameObject 필요</description></item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public class InjectorSampleNetworkManager : SingletonApp<InjectorSampleNetworkManager>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Sample
|
||||
/// Type D 예시: 순수 C# Singleton - 게임 설정 관리자
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><b>[ 타입 ]</b> Type D - 순수 C# Singleton (Singleton<T> 상속)</para>
|
||||
/// <para><b>[ 타입 ]</b> Type D - 순수 C# Singleton (Singleton<T> 상속)</para>
|
||||
/// <para><b>[ 라이프사이클 ]</b> App - 애플리케이션 전체 유지</para>
|
||||
///
|
||||
/// <para><b>[ 특징 ]</b></para>
|
||||
@@ -19,7 +19,7 @@ namespace Sample
|
||||
/// </list>
|
||||
///
|
||||
/// <para><b>[ 등록 방법 ]</b></para>
|
||||
/// <code>Injector.RegisterSingleton<InjectorSampleSettingsManager>();</code>
|
||||
/// <code>Injector.RegisterSingleton<InjectorSampleSettingsManager>();</code>
|
||||
///
|
||||
/// <para><b>[ 사용 방법 ]</b></para>
|
||||
/// <code>
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Sample
|
||||
///
|
||||
/// protected override void RegisterServices()
|
||||
/// {
|
||||
/// Injector.RegisterPrefab<IUIManager>(uiManagerPrefab.gameObject, ServiceLifetime.App);
|
||||
/// Injector.RegisterPrefab<IUIManager>(uiManagerPrefab.gameObject, ServiceLifetime.App);
|
||||
/// }
|
||||
/// </code>
|
||||
///
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Sample
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><b>구현체:</b> ConsoleLogger</para>
|
||||
/// <para><b>등록:</b> Injector.Register<ILogService, ConsoleLogger>(ServiceLifetime.App)</para>
|
||||
/// <para><b>등록:</b> Injector.Register<ILogService, ConsoleLogger>(ServiceLifetime.App)</para>
|
||||
/// <para><b>사용:</b> [Inject] private ILogService _logger;</para>
|
||||
/// </remarks>
|
||||
public interface ILogService
|
||||
@@ -73,8 +73,8 @@ namespace Sample
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><b>구현체:</b> SceneConfig</para>
|
||||
/// <para><b>등록:</b> Injector.Register<ISceneConfig, SceneConfig>(ServiceLifetime.Scene)</para>
|
||||
/// <para><b>또는 Factory:</b> Injector.RegisterFactory<ISceneConfig>(injector => new SceneConfig { ... })</para>
|
||||
/// <para><b>등록:</b> Injector.Register<ISceneConfig, SceneConfig>(ServiceLifetime.Scene)</para>
|
||||
/// <para><b>또는 Factory:</b> Injector.RegisterFactory<ISceneConfig>(injector => new SceneConfig { ... })</para>
|
||||
/// </remarks>
|
||||
public interface ISceneConfig
|
||||
{
|
||||
@@ -129,7 +129,7 @@ namespace Sample
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // 등록
|
||||
/// Injector.Register<IGameService, GameService>(ServiceLifetime.App);
|
||||
/// Injector.Register<IGameService, GameService>(ServiceLifetime.App);
|
||||
///
|
||||
/// // 사용
|
||||
/// [Inject] private IGameService _gameService;
|
||||
@@ -154,7 +154,7 @@ namespace Sample
|
||||
/// <remarks>
|
||||
/// <para><b>구현체:</b> InjectorSampleAudioManager (별도 파일)</para>
|
||||
/// <para><b>타입:</b> Type B - MonoBehaviour 동적 생성</para>
|
||||
/// <para><b>등록:</b> Injector.Register<IAudioManager, InjectorSampleAudioManager>(ServiceLifetime.App)</para>
|
||||
/// <para><b>등록:</b> Injector.Register<IAudioManager, InjectorSampleAudioManager>(ServiceLifetime.App)</para>
|
||||
/// <para><b>특징:</b> 런타임에 새 GameObject가 생성되고 AudioSource 등 Unity 컴포넌트 활용 가능</para>
|
||||
/// </remarks>
|
||||
public interface IAudioManager
|
||||
@@ -173,7 +173,7 @@ namespace Sample
|
||||
/// <remarks>
|
||||
/// <para><b>구현체:</b> InjectorSampleEnemySpawner (별도 파일)</para>
|
||||
/// <para><b>타입:</b> Type B - MonoBehaviour 동적 생성</para>
|
||||
/// <para><b>등록:</b> Injector.Register<IEnemySpawner, InjectorSampleEnemySpawner>(ServiceLifetime.Scene)</para>
|
||||
/// <para><b>등록:</b> Injector.Register<IEnemySpawner, InjectorSampleEnemySpawner>(ServiceLifetime.Scene)</para>
|
||||
/// <para><b>라이프사이클:</b> Scene - 씬 전환 시 적 스포너와 생성된 적들이 함께 정리됨</para>
|
||||
/// </remarks>
|
||||
public interface IEnemySpawner
|
||||
@@ -194,7 +194,7 @@ namespace Sample
|
||||
/// <remarks>
|
||||
/// <para><b>구현체:</b> InjectorSampleUIManager (별도 파일)</para>
|
||||
/// <para><b>타입:</b> Type C - Prefab 기반 MonoBehaviour</para>
|
||||
/// <para><b>등록:</b> Injector.RegisterPrefab<IUIManager>(uiManagerPrefab, ServiceLifetime.App)</para>
|
||||
/// <para><b>등록:</b> Injector.RegisterPrefab<IUIManager>(uiManagerPrefab, ServiceLifetime.App)</para>
|
||||
/// <para><b>특징:</b></para>
|
||||
/// <list type="bullet">
|
||||
/// <item><description>프리팹에 미리 설정된 UI 요소들이 유지됨</description></item>
|
||||
@@ -220,7 +220,7 @@ namespace Sample
|
||||
/// <remarks>
|
||||
/// <para><b>구현체:</b> InjectorSampleSceneUI (별도 파일)</para>
|
||||
/// <para><b>타입:</b> Type C - Prefab 기반 MonoBehaviour</para>
|
||||
/// <para><b>등록:</b> Injector.RegisterPrefab<ISceneUI>(sceneUIPrefab, ServiceLifetime.Scene)</para>
|
||||
/// <para><b>등록:</b> Injector.RegisterPrefab<ISceneUI>(sceneUIPrefab, ServiceLifetime.Scene)</para>
|
||||
/// <para><b>라이프사이클:</b> Scene - 씬 전환 시 UI가 함께 정리됨</para>
|
||||
/// </remarks>
|
||||
public interface ISceneUI
|
||||
@@ -268,11 +268,11 @@ namespace Sample
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// // 등록
|
||||
/// Injector.Register<IRequestHandler, RequestHandler>(ServiceLifetime.Transient);
|
||||
/// Injector.Register<IRequestHandler, RequestHandler>(ServiceLifetime.Transient);
|
||||
///
|
||||
/// // 사용 - 매번 다른 인스턴스
|
||||
/// var handler1 = Injector.Resolve<IRequestHandler>(); // RequestId: "a1b2c3d4"
|
||||
/// var handler2 = Injector.Resolve<IRequestHandler>(); // RequestId: "e5f6g7h8"
|
||||
/// var handler1 = Injector.Resolve<IRequestHandler>(); // RequestId: "a1b2c3d4"
|
||||
/// var handler2 = Injector.Resolve<IRequestHandler>(); // RequestId: "e5f6g7h8"
|
||||
/// </code>
|
||||
/// </example>
|
||||
public class RequestHandler : IRequestHandler
|
||||
|
||||
344
Assets/Sample/UIToolkit/UTKStyleGuideSample.Menu.cs
Normal file
344
Assets/Sample/UIToolkit/UTKStyleGuideSample.Menu.cs
Normal file
@@ -0,0 +1,344 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UVC.UIToolkit;
|
||||
using UVC.UI.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// UTKStyleGuideSample의 Menu 카테고리 Initialize 메서드들
|
||||
/// </summary>
|
||||
public partial class UTKStyleGuideSample
|
||||
{
|
||||
#region Menu Fields
|
||||
|
||||
private UTKTopMenu? _sampleMenuHorizontal;
|
||||
private UTKTopMenuModel? _sampleModelHorizontal;
|
||||
private UTKTopMenu? _sampleMenuIcon;
|
||||
private UTKTopMenuModel? _sampleModelIcon;
|
||||
private UTKTopMenu? _sampleMenuVertical;
|
||||
private UTKTopMenuModel? _sampleModelVertical;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Menu Initializers
|
||||
|
||||
private void InitializeTopMenuSample(VisualElement root)
|
||||
{
|
||||
InitializeHorizontalMenu(root);
|
||||
InitializeIconMenu(root);
|
||||
InitializeVerticalMenu(root);
|
||||
InitializeApiTest(root);
|
||||
|
||||
SetCodeSamples(root,
|
||||
csharpCode: @"// === 기본 가로 메뉴 ===
|
||||
var menuView = new UTKTopMenu();
|
||||
var menuModel = new UTKTopMenuModel();
|
||||
|
||||
// 메뉴 아이템 추가
|
||||
var fileMenu = new UTKMenuItemData(""file"", ""파일"");
|
||||
fileMenu.AddSubMenuItem(new UTKMenuItemData(
|
||||
""file_new"", ""새 파일"",
|
||||
new DebugLogCommand(""새 파일 생성""),
|
||||
shortcut: ""Ctrl+N""
|
||||
));
|
||||
fileMenu.AddSubMenuItem(UTKMenuItemData.CreateSeparator());
|
||||
fileMenu.AddSubMenuItem(new UTKMenuItemData(
|
||||
""file_save"", ""저장"",
|
||||
new DebugLogCommand(""저장""),
|
||||
shortcut: ""Ctrl+S""
|
||||
));
|
||||
menuModel.AddMenuItem(fileMenu);
|
||||
|
||||
// View에 메뉴 생성
|
||||
menuView.CreateMenuItems(
|
||||
menuModel.MenuItems, menuView.MenuContainer);
|
||||
|
||||
// 클릭 이벤트
|
||||
menuView.OnMenuItemClicked += (data) =>
|
||||
Debug.Log($""클릭: {data.ItemId}"");
|
||||
|
||||
// === 세로 메뉴 ===
|
||||
var vertMenu = new UTKTopMenu();
|
||||
vertMenu.Orientation = UTKMenuOrientation.Vertical;
|
||||
vertMenu.ItemSpacing = 4f;
|
||||
|
||||
// === 아이콘 메뉴 ===
|
||||
var iconMenu = new UTKMenuImageItemData(
|
||||
""settings"",
|
||||
UTKMaterialIcons.Settings,
|
||||
useMaterialIcon: true,
|
||||
imageSize: 24f
|
||||
);
|
||||
|
||||
// === API ===
|
||||
// ItemId로 Command 실행
|
||||
bool ok = menuView.ExecuteCommand(""file_new"");
|
||||
|
||||
// ItemId로 데이터 조회
|
||||
if (menuView.TryGetMenuItemData(""file_save"", out var d))
|
||||
Debug.Log($""Enabled: {d?.IsEnabled}"");",
|
||||
uxmlCode: @"<!-- 네임스페이스 선언 -->
|
||||
<ui:UXML xmlns:utk=""UVC.UIToolkit"">
|
||||
|
||||
<!-- 기본 가로 메뉴 (C#에서 동적 생성) -->
|
||||
<utk:UTKTopMenu />
|
||||
|
||||
<!-- UXML 어트리뷰트로 설정 -->
|
||||
<utk:UTKTopMenu
|
||||
orientation=""Vertical""
|
||||
item-spacing=""4"" />
|
||||
|
||||
</ui:UXML>");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 가로 메뉴 초기화
|
||||
/// </summary>
|
||||
private void InitializeHorizontalMenu(VisualElement root)
|
||||
{
|
||||
var container = root.Q<VisualElement>("horizontal-menu-container");
|
||||
if (container == null) return;
|
||||
|
||||
_sampleMenuHorizontal = new UTKTopMenu();
|
||||
_sampleModelHorizontal = new UTKTopMenuModel();
|
||||
|
||||
// 파일 메뉴
|
||||
var fileMenu = new UTKMenuItemData("s_file", "파일");
|
||||
fileMenu.AddSubMenuItem(new UTKMenuItemData("s_file_new", "새 파일", new DebugLogCommand("새 파일 생성"), shortcut: "Ctrl+N"));
|
||||
fileMenu.AddSubMenuItem(new UTKMenuItemData("s_file_open", "열기", new DebugLogCommand("파일 열기"), shortcut: "Ctrl+O"));
|
||||
fileMenu.AddSubMenuItem(UTKMenuItemData.CreateSeparator());
|
||||
fileMenu.AddSubMenuItem(new UTKMenuItemData("s_file_save", "저장", new DebugLogCommand("파일 저장"), shortcut: "Ctrl+S"));
|
||||
fileMenu.AddSubMenuItem(new UTKMenuItemData("s_file_exit", "종료", new DebugLogCommand("종료"), shortcut: "Alt+F4"));
|
||||
_sampleModelHorizontal.AddMenuItem(fileMenu);
|
||||
|
||||
// 편집 메뉴
|
||||
var editMenu = new UTKMenuItemData("s_edit", "편집");
|
||||
editMenu.AddSubMenuItem(new UTKMenuItemData("s_edit_undo", "실행 취소", new DebugLogCommand("실행 취소"), shortcut: "Ctrl+Z"));
|
||||
editMenu.AddSubMenuItem(new UTKMenuItemData("s_edit_redo", "다시 실행", new DebugLogCommand("다시 실행"), shortcut: "Ctrl+Y"));
|
||||
editMenu.AddSubMenuItem(UTKMenuItemData.CreateSeparator());
|
||||
editMenu.AddSubMenuItem(new UTKMenuItemData("s_edit_copy", "복사", new DebugLogCommand("복사"), shortcut: "Ctrl+C"));
|
||||
editMenu.AddSubMenuItem(new UTKMenuItemData("s_edit_paste", "붙여넣기", new DebugLogCommand("붙여넣기"), shortcut: "Ctrl+V"));
|
||||
_sampleModelHorizontal.AddMenuItem(editMenu);
|
||||
|
||||
// 보기 메뉴 (2 depth)
|
||||
var viewMenu = new UTKMenuItemData("s_view", "보기");
|
||||
var layoutMenu = new UTKMenuItemData("s_view_layout", "레이아웃");
|
||||
layoutMenu.AddSubMenuItem(new UTKMenuItemData("s_view_layout_default", "기본", new DebugLogCommand("기본 레이아웃")));
|
||||
layoutMenu.AddSubMenuItem(new UTKMenuItemData("s_view_layout_wide", "와이드", new DebugLogCommand("와이드 레이아웃")));
|
||||
viewMenu.AddSubMenuItem(layoutMenu);
|
||||
viewMenu.AddSubMenuItem(new UTKMenuItemData("s_view_fullscreen", "전체 화면", new DebugLogCommand("전체 화면"), shortcut: "F11"));
|
||||
_sampleModelHorizontal.AddMenuItem(viewMenu);
|
||||
|
||||
// 도움말 메뉴
|
||||
var helpMenu = new UTKMenuItemData("s_help", "도움말");
|
||||
helpMenu.AddSubMenuItem(new UTKMenuItemData("s_help_doc", "문서", new DebugLogCommand("문서 열기"), shortcut: "F1"));
|
||||
helpMenu.AddSubMenuItem(new UTKMenuItemData("s_help_about", "정보", new DebugLogCommand("정보")));
|
||||
_sampleModelHorizontal.AddMenuItem(helpMenu);
|
||||
|
||||
// View에 메뉴 생성
|
||||
if (_sampleMenuHorizontal.MenuContainer != null)
|
||||
{
|
||||
_sampleMenuHorizontal.CreateMenuItems(_sampleModelHorizontal.MenuItems, _sampleMenuHorizontal.MenuContainer);
|
||||
}
|
||||
|
||||
_sampleMenuHorizontal.OnMenuItemClicked += OnSampleMenuClicked;
|
||||
container.Add(_sampleMenuHorizontal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 아이콘 메뉴 초기화 (ItemSpacing 적용)
|
||||
/// </summary>
|
||||
private void InitializeIconMenu(VisualElement root)
|
||||
{
|
||||
var container = root.Q<VisualElement>("icon-menu-container");
|
||||
if (container == null) return;
|
||||
|
||||
_sampleMenuIcon = new UTKTopMenu();
|
||||
_sampleMenuIcon.ItemSpacing = 4f;
|
||||
_sampleModelIcon = new UTKTopMenuModel();
|
||||
|
||||
// 홈 아이콘
|
||||
var homeMenu = new UTKMenuImageItemData("s_icon_home", UTKMaterialIcons.Home, useMaterialIcon: true, imageSize: 24f);
|
||||
homeMenu.AddSubMenuItem(new UTKMenuItemData("s_icon_home_dashboard", "대시보드", new DebugLogCommand("대시보드")));
|
||||
homeMenu.AddSubMenuItem(new UTKMenuItemData("s_icon_home_recent", "최근 항목", new DebugLogCommand("최근 항목")));
|
||||
_sampleModelIcon.AddMenuItem(homeMenu);
|
||||
|
||||
// 설정 아이콘
|
||||
var settingsMenu = new UTKMenuImageItemData("s_icon_settings", UTKMaterialIcons.Settings, useMaterialIcon: true, imageSize: 24f);
|
||||
settingsMenu.AddSubMenuItem(new UTKMenuItemData("s_icon_settings_general", "일반", new DebugLogCommand("일반 설정")));
|
||||
settingsMenu.AddSubMenuItem(new UTKMenuItemData("s_icon_settings_display", "화면", new DebugLogCommand("화면 설정")));
|
||||
_sampleModelIcon.AddMenuItem(settingsMenu);
|
||||
|
||||
// 알림 아이콘
|
||||
var notifMenu = new UTKMenuImageItemData("s_icon_notif", UTKMaterialIcons.Notifications, useMaterialIcon: true, imageSize: 24f);
|
||||
notifMenu.AddSubMenuItem(new UTKMenuItemData("s_icon_notif_all", "전체 알림", new DebugLogCommand("전체 알림")));
|
||||
notifMenu.AddSubMenuItem(new UTKMenuItemData("s_icon_notif_clear", "알림 지우기", new DebugLogCommand("알림 지우기")));
|
||||
_sampleModelIcon.AddMenuItem(notifMenu);
|
||||
|
||||
// 계정 아이콘
|
||||
var accountMenu = new UTKMenuImageItemData("s_icon_account", UTKMaterialIcons.AccountCircle, useMaterialIcon: true, imageSize: 24f);
|
||||
accountMenu.AddSubMenuItem(new UTKMenuItemData("s_icon_account_profile", "프로필", new DebugLogCommand("프로필")));
|
||||
accountMenu.AddSubMenuItem(new UTKMenuItemData("s_icon_account_logout", "로그아웃", new DebugLogCommand("로그아웃")));
|
||||
_sampleModelIcon.AddMenuItem(accountMenu);
|
||||
|
||||
if (_sampleMenuIcon.MenuContainer != null)
|
||||
{
|
||||
_sampleMenuIcon.CreateMenuItems(_sampleModelIcon.MenuItems, _sampleMenuIcon.MenuContainer);
|
||||
}
|
||||
|
||||
_sampleMenuIcon.OnMenuItemClicked += OnSampleMenuClicked;
|
||||
container.Add(_sampleMenuIcon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 세로 메뉴 초기화
|
||||
/// </summary>
|
||||
private void InitializeVerticalMenu(VisualElement root)
|
||||
{
|
||||
var container = root.Q<VisualElement>("vertical-menu-container");
|
||||
if (container == null) return;
|
||||
|
||||
_sampleMenuVertical = new UTKTopMenu();
|
||||
_sampleMenuVertical.Orientation = UTKMenuOrientation.Vertical;
|
||||
_sampleMenuVertical.ItemSpacing = 2f;
|
||||
_sampleMenuVertical.SubMenuOffsetX = -10f;
|
||||
_sampleMenuVertical.SubMenuOffsetY = 4f;
|
||||
_sampleModelVertical = new UTKTopMenuModel();
|
||||
|
||||
// 파일
|
||||
var fileMenu = new UTKMenuItemData("sv_file", "파일");
|
||||
fileMenu.AddSubMenuItem(new UTKMenuItemData("sv_file_new", "새 파일", new DebugLogCommand("세로: 새 파일"), shortcut: "Ctrl+N"));
|
||||
fileMenu.AddSubMenuItem(new UTKMenuItemData("sv_file_open", "열기", new DebugLogCommand("세로: 열기"), shortcut: "Ctrl+O"));
|
||||
fileMenu.AddSubMenuItem(UTKMenuItemData.CreateSeparator());
|
||||
fileMenu.AddSubMenuItem(new UTKMenuItemData("sv_file_save", "저장", new DebugLogCommand("세로: 저장"), shortcut: "Ctrl+S"));
|
||||
_sampleModelVertical.AddMenuItem(fileMenu);
|
||||
|
||||
// 편집
|
||||
var editMenu = new UTKMenuItemData("sv_edit", "편집");
|
||||
editMenu.AddSubMenuItem(new UTKMenuItemData("sv_edit_undo", "실행 취소", new DebugLogCommand("세로: 실행 취소"), shortcut: "Ctrl+Z"));
|
||||
editMenu.AddSubMenuItem(new UTKMenuItemData("sv_edit_redo", "다시 실행", new DebugLogCommand("세로: 다시 실행"), shortcut: "Ctrl+Y"));
|
||||
_sampleModelVertical.AddMenuItem(editMenu);
|
||||
|
||||
// 보기
|
||||
var viewMenu = new UTKMenuItemData("sv_view", "보기");
|
||||
viewMenu.AddSubMenuItem(new UTKMenuItemData("sv_view_fullscreen", "전체 화면", new DebugLogCommand("세로: 전체 화면"), shortcut: "F11"));
|
||||
_sampleModelVertical.AddMenuItem(viewMenu);
|
||||
|
||||
// 도움말
|
||||
var helpMenu = new UTKMenuItemData("sv_help", "도움말");
|
||||
helpMenu.AddSubMenuItem(new UTKMenuItemData("sv_help_about", "정보", new DebugLogCommand("세로: 정보")));
|
||||
_sampleModelVertical.AddMenuItem(helpMenu);
|
||||
|
||||
if (_sampleMenuVertical.MenuContainer != null)
|
||||
{
|
||||
_sampleMenuVertical.CreateMenuItems(_sampleModelVertical.MenuItems, _sampleMenuVertical.MenuContainer);
|
||||
}
|
||||
|
||||
_sampleMenuVertical.OnMenuItemClicked += OnSampleMenuClicked;
|
||||
container.Add(_sampleMenuVertical);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API 테스트 버튼 초기화
|
||||
/// </summary>
|
||||
private void InitializeApiTest(VisualElement root)
|
||||
{
|
||||
var container = root.Q<VisualElement>("api-test-container");
|
||||
var resultLabel = root.Q<Label>("api-result-label");
|
||||
if (container == null || resultLabel == null) return;
|
||||
|
||||
// ExecuteCommand 테스트
|
||||
var executeBtn = new UTKButton("ExecuteCommand");
|
||||
executeBtn.OnClicked += () =>
|
||||
{
|
||||
if (_sampleMenuHorizontal == null) return;
|
||||
|
||||
bool result = _sampleMenuHorizontal.ExecuteCommand("s_file_new");
|
||||
resultLabel.text = $"ExecuteCommand(\"s_file_new\"): {result}";
|
||||
};
|
||||
container.Add(executeBtn);
|
||||
|
||||
// TryGetMenuItemData 테스트
|
||||
var getDataBtn = new UTKButton("TryGetMenuItemData");
|
||||
getDataBtn.OnClicked += () =>
|
||||
{
|
||||
if (_sampleMenuHorizontal == null) return;
|
||||
|
||||
if (_sampleMenuHorizontal.TryGetMenuItemData("s_file_save", out var data))
|
||||
{
|
||||
resultLabel.text = $"TryGetMenuItemData(\"s_file_save\"): " +
|
||||
$"DisplayName={data?.DisplayName}, " +
|
||||
$"IsEnabled={data?.IsEnabled}, " +
|
||||
$"Shortcut={data?.Shortcut}";
|
||||
}
|
||||
else
|
||||
{
|
||||
resultLabel.text = "TryGetMenuItemData(\"s_file_save\"): 찾을 수 없음";
|
||||
}
|
||||
};
|
||||
container.Add(getDataBtn);
|
||||
|
||||
// CloseAllOpenSubMenus 테스트
|
||||
var closeBtn = new UTKButton("CloseAll");
|
||||
closeBtn.OnClicked += () =>
|
||||
{
|
||||
_sampleMenuHorizontal?.CloseAllOpenSubMenus();
|
||||
_sampleMenuIcon?.CloseAllOpenSubMenus();
|
||||
_sampleMenuVertical?.CloseAllOpenSubMenus();
|
||||
resultLabel.text = "모든 서브메뉴 닫기 완료";
|
||||
};
|
||||
container.Add(closeBtn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 샘플 메뉴 클릭 핸들러
|
||||
/// </summary>
|
||||
private void OnSampleMenuClicked(UTKMenuItemData itemData)
|
||||
{
|
||||
if (itemData == null) return;
|
||||
Debug.Log($"[UTKTopMenu Sample] 클릭: {itemData.ItemId} - {itemData.DisplayName}");
|
||||
|
||||
if (itemData.Command != null)
|
||||
{
|
||||
itemData.Command.Execute(itemData.CommandParameter);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 메뉴 샘플 리소스 정리
|
||||
/// </summary>
|
||||
private void CleanupTopMenuSample()
|
||||
{
|
||||
if (_sampleMenuHorizontal != null)
|
||||
{
|
||||
_sampleMenuHorizontal.OnMenuItemClicked -= OnSampleMenuClicked;
|
||||
_sampleMenuHorizontal.Dispose();
|
||||
_sampleMenuHorizontal = null;
|
||||
}
|
||||
|
||||
if (_sampleMenuIcon != null)
|
||||
{
|
||||
_sampleMenuIcon.OnMenuItemClicked -= OnSampleMenuClicked;
|
||||
_sampleMenuIcon.Dispose();
|
||||
_sampleMenuIcon = null;
|
||||
}
|
||||
|
||||
if (_sampleMenuVertical != null)
|
||||
{
|
||||
_sampleMenuVertical.OnMenuItemClicked -= OnSampleMenuClicked;
|
||||
_sampleMenuVertical.Dispose();
|
||||
_sampleMenuVertical = null;
|
||||
}
|
||||
|
||||
_sampleModelHorizontal?.Dispose();
|
||||
_sampleModelHorizontal = null;
|
||||
_sampleModelIcon?.Dispose();
|
||||
_sampleModelIcon = null;
|
||||
_sampleModelVertical?.Dispose();
|
||||
_sampleModelVertical = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
2
Assets/Sample/UIToolkit/UTKStyleGuideSample.Menu.cs.meta
Normal file
2
Assets/Sample/UIToolkit/UTKStyleGuideSample.Menu.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4fd209bb41271e4fb58e784d869403e
|
||||
328
Assets/Sample/UIToolkit/UTKStyleGuideSample.ToolBar.cs
Normal file
328
Assets/Sample/UIToolkit/UTKStyleGuideSample.ToolBar.cs
Normal file
@@ -0,0 +1,328 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UVC.UIToolkit;
|
||||
using UVC.UI.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// UTKStyleGuideSample의 ToolBar 카테고리 Initialize 메서드들
|
||||
/// </summary>
|
||||
public partial class UTKStyleGuideSample
|
||||
{
|
||||
#region ToolBar Fields
|
||||
|
||||
private UTKToolBar? _sampleToolBarHorizontal;
|
||||
private UTKToolBarModel? _sampleToolBarModelHorizontal;
|
||||
private UTKToolBar? _sampleToolBarVertical;
|
||||
private UTKToolBarModel? _sampleToolBarModelVertical;
|
||||
private Label? _toolBarEventLogLabel;
|
||||
private readonly List<string> _toolBarEventLogs = new();
|
||||
private const int MaxToolBarLogLines = 5;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToolBar Initializers
|
||||
|
||||
private void InitializeToolBarSample(VisualElement root)
|
||||
{
|
||||
_toolBarEventLogLabel = root.Q<Label>("event-log-label");
|
||||
|
||||
InitializeHorizontalToolBar(root);
|
||||
InitializeVerticalToolBar(root);
|
||||
InitializeToolBarApiTest(root);
|
||||
|
||||
SetCodeSamples(root,
|
||||
csharpCode: @"// === 가로 툴바 ===
|
||||
var model = new UTKToolBarModel();
|
||||
|
||||
// Standard 버튼
|
||||
model.AddStandardButton(""저장"", UTKMaterialIcons.Save);
|
||||
|
||||
// 구분선
|
||||
model.AddSeparator();
|
||||
|
||||
// Toggle 버튼
|
||||
model.AddToggleButton(""그리드"", false,
|
||||
UTKMaterialIcons.GridOn,
|
||||
UTKMaterialIcons.GridOff);
|
||||
|
||||
// Radio 버튼 그룹
|
||||
model.AddRadioButton(""tool"", ""선택"", true,
|
||||
UTKMaterialIcons.NearMe);
|
||||
model.AddRadioButton(""tool"", ""이동"", false,
|
||||
UTKMaterialIcons.OpenWith);
|
||||
|
||||
model.AddSeparator();
|
||||
|
||||
// Expandable 버튼 (서브 메뉴)
|
||||
var shapes = model.AddExpandableButton(""도형"",
|
||||
UTKMaterialIcons.Category, updateIconOnSelection: true);
|
||||
shapes.SubButtons.Add(
|
||||
new UTKToolBarStandardButtonData
|
||||
{ Text = ""사각형"", IconPath = UTKMaterialIcons.CropSquare,
|
||||
UseMaterialIcon = true });
|
||||
shapes.SubButtons.Add(
|
||||
new UTKToolBarStandardButtonData
|
||||
{ Text = ""원형"", IconPath = UTKMaterialIcons.Circle,
|
||||
UseMaterialIcon = true });
|
||||
|
||||
// View 생성 및 빌드
|
||||
var toolbar = new UTKToolBar();
|
||||
toolbar.Orientation = UTKToolBarOrientation.Horizontal;
|
||||
parent.Add(toolbar);
|
||||
toolbar.BuildToolBar(model);
|
||||
|
||||
// 이벤트 구독
|
||||
toolbar.OnAction += args =>
|
||||
Debug.Log($""{args.Text}: {args.ActionType}"");
|
||||
|
||||
// === 세로 배치로 전환 ===
|
||||
toolbar.SetOrientation(UTKToolBarOrientation.Vertical);
|
||||
|
||||
// === API ===
|
||||
// 토글 상태 변경
|
||||
model.SetToggleButtonStateByText(""그리드"", true);
|
||||
// 라디오 선택 변경
|
||||
model.SetRadioButtonSelectionByText(""tool"", ""이동"");",
|
||||
uxmlCode: @"<!-- 네임스페이스 선언 -->
|
||||
<ui:UXML xmlns:utk=""UVC.UIToolkit"">
|
||||
|
||||
<!-- UXML에서 직접 사용 -->
|
||||
<utk:UTKToolBar orientation=""Horizontal""
|
||||
item-spacing=""2""
|
||||
toolbar-size=""40"" />
|
||||
|
||||
<!-- 세로 배치 -->
|
||||
<utk:UTKToolBar orientation=""Vertical"" />
|
||||
|
||||
</ui:UXML>");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 가로 툴바 초기화
|
||||
/// </summary>
|
||||
private void InitializeHorizontalToolBar(VisualElement root)
|
||||
{
|
||||
var container = root.Q<VisualElement>("horizontal-toolbar-container");
|
||||
if (container == null) return;
|
||||
|
||||
_sampleToolBarModelHorizontal = new UTKToolBarModel();
|
||||
|
||||
// Standard 버튼들
|
||||
_sampleToolBarModelHorizontal.AddStandardButton("저장", UTKMaterialIcons.Save, new DebugLogCommand("저장"), "파일 저장");
|
||||
_sampleToolBarModelHorizontal.AddStandardButton("실행 취소", UTKMaterialIcons.Undo, new DebugLogCommand("실행 취소"), "실행 취소");
|
||||
_sampleToolBarModelHorizontal.AddStandardButton("다시 실행", UTKMaterialIcons.Redo, new DebugLogCommand("다시 실행"), "다시 실행");
|
||||
|
||||
_sampleToolBarModelHorizontal.AddSeparator();
|
||||
|
||||
// Toggle 버튼들
|
||||
_sampleToolBarModelHorizontal.AddToggleButton("그리드", false,
|
||||
UTKMaterialIcons.GridOn, UTKMaterialIcons.GridOff,
|
||||
isOn => AppendToolBarLog($"그리드: {(isOn ? "ON" : "OFF")}"),
|
||||
tooltip: "그리드 표시/숨김");
|
||||
_sampleToolBarModelHorizontal.AddToggleButton("스냅", false,
|
||||
UTKMaterialIcons.FilterCenterFocus, UTKMaterialIcons.CenterFocusWeak,
|
||||
isOn => AppendToolBarLog($"스냅: {(isOn ? "ON" : "OFF")}"),
|
||||
tooltip: "스냅 활성화/비활성화");
|
||||
|
||||
_sampleToolBarModelHorizontal.AddSeparator();
|
||||
|
||||
// Radio 버튼 그룹 (도구 선택)
|
||||
_sampleToolBarModelHorizontal.AddRadioButton("tool", "선택", true,
|
||||
UTKMaterialIcons.NearMe, null,
|
||||
isOn => { if (isOn) AppendToolBarLog("도구: 선택"); },
|
||||
tooltip: "선택 도구");
|
||||
_sampleToolBarModelHorizontal.AddRadioButton("tool", "이동", false,
|
||||
UTKMaterialIcons.OpenWith, null,
|
||||
isOn => { if (isOn) AppendToolBarLog("도구: 이동"); },
|
||||
tooltip: "이동 도구");
|
||||
_sampleToolBarModelHorizontal.AddRadioButton("tool", "회전", false,
|
||||
UTKMaterialIcons.Refresh, null,
|
||||
isOn => { if (isOn) AppendToolBarLog("도구: 회전"); },
|
||||
tooltip: "회전 도구");
|
||||
_sampleToolBarModelHorizontal.AddRadioButton("tool", "크기", false,
|
||||
UTKMaterialIcons.AspectRatio, null,
|
||||
isOn => { if (isOn) AppendToolBarLog("도구: 크기"); },
|
||||
tooltip: "크기 도구");
|
||||
|
||||
_sampleToolBarModelHorizontal.AddSeparator();
|
||||
|
||||
// Expandable 버튼 (도형)
|
||||
var shapeBtn = _sampleToolBarModelHorizontal.AddExpandableButton("도형",
|
||||
UTKMaterialIcons.Category, tooltip: "도형 추가", updateIconOnSelection: true);
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "사각형", IconPath = UTKMaterialIcons.CropSquare, UseMaterialIcon = true });
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "원형", IconPath = UTKMaterialIcons.Circle, UseMaterialIcon = true });
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "삼각형", IconPath = UTKMaterialIcons.ChangeHistory, UseMaterialIcon = true });
|
||||
|
||||
// View 생성
|
||||
_sampleToolBarHorizontal = new UTKToolBar();
|
||||
_sampleToolBarHorizontal.Orientation = UTKToolBarOrientation.Horizontal;
|
||||
|
||||
_sampleToolBarHorizontal.OnAction += OnToolBarSampleAction;
|
||||
_sampleToolBarHorizontal.BuildToolBar(_sampleToolBarModelHorizontal);
|
||||
|
||||
container.Add(_sampleToolBarHorizontal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 세로 툴바 초기화
|
||||
/// </summary>
|
||||
private void InitializeVerticalToolBar(VisualElement root)
|
||||
{
|
||||
var container = root.Q<VisualElement>("vertical-toolbar-container");
|
||||
if (container == null) return;
|
||||
|
||||
_sampleToolBarModelVertical = new UTKToolBarModel();
|
||||
|
||||
// Standard 버튼들 (아이콘만)
|
||||
_sampleToolBarModelVertical.AddStandardButton("", UTKMaterialIcons.Save, new DebugLogCommand("세로: 저장"), "저장");
|
||||
_sampleToolBarModelVertical.AddStandardButton("", UTKMaterialIcons.Undo, new DebugLogCommand("세로: 실행 취소"), "실행 취소");
|
||||
|
||||
_sampleToolBarModelVertical.AddSeparator();
|
||||
|
||||
// Toggle 버튼
|
||||
_sampleToolBarModelVertical.AddToggleButton("", false,
|
||||
UTKMaterialIcons.Visibility, UTKMaterialIcons.VisibilityOff,
|
||||
tooltip: "표시/숨김");
|
||||
_sampleToolBarModelVertical.AddToggleButton("", false,
|
||||
UTKMaterialIcons.Lock, UTKMaterialIcons.LockOpen,
|
||||
tooltip: "잠금/해제");
|
||||
|
||||
_sampleToolBarModelVertical.AddSeparator();
|
||||
|
||||
// Radio 버튼 그룹
|
||||
_sampleToolBarModelVertical.AddRadioButton("vtool", "", true,
|
||||
UTKMaterialIcons.NearMe, null, tooltip: "선택 도구");
|
||||
_sampleToolBarModelVertical.AddRadioButton("vtool", "", false,
|
||||
UTKMaterialIcons.OpenWith, null, tooltip: "이동 도구");
|
||||
_sampleToolBarModelVertical.AddRadioButton("vtool", "", false,
|
||||
UTKMaterialIcons.Refresh, null, tooltip: "회전 도구");
|
||||
|
||||
_sampleToolBarModelVertical.AddSeparator();
|
||||
|
||||
// Expandable 버튼 (도형)
|
||||
var shapeBtn = _sampleToolBarModelVertical.AddExpandableButton("",
|
||||
UTKMaterialIcons.Category, tooltip: "도형 추가", updateIconOnSelection: true);
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "사각형", IconPath = UTKMaterialIcons.CropSquare, UseMaterialIcon = true });
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "원형", IconPath = UTKMaterialIcons.Circle, UseMaterialIcon = true });
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "삼각형", IconPath = UTKMaterialIcons.ChangeHistory, UseMaterialIcon = true });
|
||||
|
||||
// View 생성
|
||||
_sampleToolBarVertical = new UTKToolBar();
|
||||
_sampleToolBarVertical.Orientation = UTKToolBarOrientation.Vertical;
|
||||
|
||||
_sampleToolBarVertical.OnAction += OnToolBarSampleAction;
|
||||
_sampleToolBarVertical.BuildToolBar(_sampleToolBarModelVertical);
|
||||
|
||||
container.Add(_sampleToolBarVertical);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API 테스트 버튼 초기화
|
||||
/// </summary>
|
||||
private void InitializeToolBarApiTest(VisualElement root)
|
||||
{
|
||||
var container = root.Q<VisualElement>("api-test-container");
|
||||
var resultLabel = root.Q<Label>("api-result-label");
|
||||
if (container == null || resultLabel == null) return;
|
||||
|
||||
// SetToggleButtonState 테스트
|
||||
var toggleBtn = new UTKButton("Toggle Grid ON");
|
||||
toggleBtn.OnClicked += () =>
|
||||
{
|
||||
if (_sampleToolBarModelHorizontal == null) return;
|
||||
_sampleToolBarModelHorizontal.SetToggleButtonStateByText("그리드", true, true);
|
||||
resultLabel.text = "SetToggleButtonStateByText(\"그리드\", true) 실행됨";
|
||||
};
|
||||
container.Add(toggleBtn);
|
||||
|
||||
// SetRadioButtonSelection 테스트
|
||||
var radioBtn = new UTKButton("Select 이동");
|
||||
radioBtn.OnClicked += () =>
|
||||
{
|
||||
if (_sampleToolBarModelHorizontal == null) return;
|
||||
_sampleToolBarModelHorizontal.SetRadioButtonSelectionByText("tool", "이동", true);
|
||||
resultLabel.text = "SetRadioButtonSelectionByText(\"tool\", \"이동\") 실행됨";
|
||||
};
|
||||
container.Add(radioBtn);
|
||||
|
||||
// ClearRadioButtonSelection 테스트
|
||||
var clearBtn = new UTKButton("Clear Radio");
|
||||
clearBtn.OnClicked += () =>
|
||||
{
|
||||
if (_sampleToolBarModelHorizontal == null) return;
|
||||
_sampleToolBarModelHorizontal.ClearRadioButtonSelection("tool", true);
|
||||
resultLabel.text = "ClearRadioButtonSelection(\"tool\") 실행됨";
|
||||
};
|
||||
container.Add(clearBtn);
|
||||
|
||||
// GetToggleButtonState 테스트
|
||||
var getStateBtn = new UTKButton("Get Grid State");
|
||||
getStateBtn.OnClicked += () =>
|
||||
{
|
||||
if (_sampleToolBarModelHorizontal == null) return;
|
||||
bool state = _sampleToolBarModelHorizontal.GetToggleButtonState("그리드");
|
||||
resultLabel.text = $"GetToggleButtonState(\"그리드\"): {state}";
|
||||
};
|
||||
container.Add(getStateBtn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 툴바 액션 이벤트 핸들러
|
||||
/// </summary>
|
||||
private void OnToolBarSampleAction(UTKToolBarActionEventArgs args)
|
||||
{
|
||||
string valueStr = args.Value != null ? args.Value.ToString() ?? "" : "null";
|
||||
string logEntry = $"[{args.ActionType}] {args.Text}: {valueStr}";
|
||||
Debug.Log($"[UTKToolBar Sample] {logEntry}");
|
||||
AppendToolBarLog(logEntry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 이벤트 로그에 항목을 추가합니다.
|
||||
/// </summary>
|
||||
private void AppendToolBarLog(string message)
|
||||
{
|
||||
_toolBarEventLogs.Add(message);
|
||||
while (_toolBarEventLogs.Count > MaxToolBarLogLines)
|
||||
{
|
||||
_toolBarEventLogs.RemoveAt(0);
|
||||
}
|
||||
if (_toolBarEventLogLabel != null)
|
||||
{
|
||||
_toolBarEventLogLabel.text = string.Join("\n", _toolBarEventLogs);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 툴바 샘플 리소스 정리
|
||||
/// </summary>
|
||||
private void CleanupToolBarSample()
|
||||
{
|
||||
if (_sampleToolBarHorizontal != null)
|
||||
{
|
||||
_sampleToolBarHorizontal.OnAction -= OnToolBarSampleAction;
|
||||
_sampleToolBarHorizontal.Dispose();
|
||||
_sampleToolBarHorizontal = null;
|
||||
}
|
||||
|
||||
if (_sampleToolBarVertical != null)
|
||||
{
|
||||
_sampleToolBarVertical.OnAction -= OnToolBarSampleAction;
|
||||
_sampleToolBarVertical.Dispose();
|
||||
_sampleToolBarVertical = null;
|
||||
}
|
||||
|
||||
_sampleToolBarModelHorizontal?.Dispose();
|
||||
_sampleToolBarModelHorizontal = null;
|
||||
_sampleToolBarModelVertical?.Dispose();
|
||||
_sampleToolBarModelVertical = null;
|
||||
|
||||
_toolBarEventLogs.Clear();
|
||||
_toolBarEventLogLabel = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9442e732448071f4eb1183d73ac6421b
|
||||
@@ -100,6 +100,10 @@ public partial class UTKStyleGuideSample : MonoBehaviour
|
||||
// Picker
|
||||
["UTKColorPicker"] = "UIToolkit/Sample/Picker/UTKColorPickerSample",
|
||||
["UTKDatePicker"] = "UIToolkit/Sample/Picker/UTKDatePickerSample",
|
||||
// Menu
|
||||
["UTKTopMenu"] = "UIToolkit/Sample/Menu/UTKTopMenuSample",
|
||||
// ToolBar
|
||||
["UTKToolBar"] = "UIToolkit/Sample/ToolBar/UTKToolBarSample",
|
||||
// Window
|
||||
["UTKAccordionListWindow"] = "UIToolkit/Sample/Window/UTKAccordionListWindowSample",
|
||||
["UTKComponentListWindow"] = "UIToolkit/Sample/Window/UTKComponentListWindowSample",
|
||||
@@ -122,6 +126,8 @@ public partial class UTKStyleGuideSample : MonoBehaviour
|
||||
["Tab"] = new[] { "UTKTabView" },
|
||||
["Modal"] = new[] { "UTKAlert", "UTKToast", "UTKTooltip" },
|
||||
["Picker"] = new[] { "UTKColorPicker", "UTKDatePicker" },
|
||||
["Menu"] = new[] { "UTKTopMenu" },
|
||||
["ToolBar"] = new[] { "UTKToolBar" },
|
||||
["Window"] = new[] { "UTKAccordionListWindow", "UTKComponentListWindow", "UTKComponentTabListWindow", "UTKImageListWindow", "UTKTreeListWindow", "UTKPropertyListWindow" },
|
||||
};
|
||||
|
||||
@@ -558,6 +564,14 @@ public partial class UTKStyleGuideSample : MonoBehaviour
|
||||
case "UTKImage":
|
||||
InitializeUTKImageSample(root);
|
||||
break;
|
||||
// Menu
|
||||
case "UTKTopMenu":
|
||||
InitializeTopMenuSample(root);
|
||||
break;
|
||||
// ToolBar
|
||||
case "UTKToolBar":
|
||||
InitializeToolBarSample(root);
|
||||
break;
|
||||
// Window
|
||||
case "UTKAccordionListWindow":
|
||||
InitializeAccordionListWindowSample(root);
|
||||
|
||||
497
Assets/Sample/UIToolkit/UTKToolBar.unity
Normal file
497
Assets/Sample/UIToolkit/UTKToolBar.unity
Normal file
@@ -0,0 +1,497 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 10
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 13
|
||||
m_BakeOnSceneLoad: 0
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 256
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRDenoiserTypeDirect: 1
|
||||
m_PVRDenoiserTypeIndirect: 1
|
||||
m_PVRDenoiserTypeAO: 1
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 1
|
||||
m_PVRFilteringGaussRadiusAO: 1
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_LightingSettings: {fileID: 0}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 3
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
buildHeightMesh: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &1097328750
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1097328752}
|
||||
- component: {fileID: 1097328754}
|
||||
- component: {fileID: 1097328755}
|
||||
m_Layer: 0
|
||||
m_Name: Sample
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1097328752
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1097328750}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1097328754
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1097328750}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.dll::UnityEngine.UIElements.UIDocument
|
||||
m_PanelSettings: {fileID: 11400000, guid: 5ad7007b08a97b54d927c352279a18b6, type: 2}
|
||||
m_ParentUI: {fileID: 0}
|
||||
sourceAsset: {fileID: 9197481963319205126, guid: 54e4f33c8b08cb54f97dbdb5edd79e1e, type: 3}
|
||||
m_SortingOrder: 1
|
||||
m_Position: 0
|
||||
m_WorldSpaceSizeMode: 1
|
||||
m_WorldSpaceWidth: 1920
|
||||
m_WorldSpaceHeight: 1080
|
||||
m_PivotReferenceSize: 0
|
||||
m_Pivot: 0
|
||||
m_WorldSpaceCollider: {fileID: 0}
|
||||
--- !u!114 &1097328755
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1097328750}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 39265a781c40bdb4a90aa56b0fbf44a6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::UVC.Sample.UIToolkit.UTKToolBarSample
|
||||
_uiDocument: {fileID: 1097328754}
|
||||
initialTheme: 0
|
||||
--- !u!1 &1331954412
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1331954415}
|
||||
- component: {fileID: 1331954414}
|
||||
- component: {fileID: 1331954413}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1331954413
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1331954412}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_MoveRepeatDelay: 0.5
|
||||
m_MoveRepeatRate: 0.1
|
||||
m_XRTrackingOrigin: {fileID: 0}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_DeselectOnBackgroundClick: 0
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
m_ScrollDeltaPerTick: 6
|
||||
--- !u!114 &1331954414
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1331954412}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 1
|
||||
m_DragThreshold: 10
|
||||
--- !u!4 &1331954415
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1331954412}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1414861612
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1414861614}
|
||||
- component: {fileID: 1414861613}
|
||||
- component: {fileID: 1414861615}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &1414861613
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1414861612}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 11
|
||||
m_Type: 1
|
||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ForceVisible: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
m_LightUnit: 1
|
||||
m_LuxAtDistance: 1
|
||||
m_EnableSpotReflector: 1
|
||||
--- !u!4 &1414861614
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1414861612}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!114 &1414861615
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1414861612}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UsePipelineSettings: 1
|
||||
m_AdditionalLightsShadowResolutionTier: 2
|
||||
m_CustomShadowLayers: 0
|
||||
m_LightCookieSize: {x: 1, y: 1}
|
||||
m_LightCookieOffset: {x: 0, y: 0}
|
||||
m_SoftShadowQuality: 0
|
||||
m_RenderingLayersMask:
|
||||
serializedVersion: 0
|
||||
m_Bits: 1
|
||||
m_ShadowRenderingLayersMask:
|
||||
serializedVersion: 0
|
||||
m_Bits: 1
|
||||
m_Version: 4
|
||||
m_LightLayerMask: 1
|
||||
m_ShadowLayerMask: 1
|
||||
m_RenderingLayers: 1
|
||||
m_ShadowRenderingLayers: 1
|
||||
--- !u!1 &2136621999
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2136622002}
|
||||
- component: {fileID: 2136622001}
|
||||
- component: {fileID: 2136622000}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &2136622000
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2136621999}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &2136622001
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2136621999}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &2136622002
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2136621999}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 2136622002}
|
||||
- {fileID: 1414861614}
|
||||
- {fileID: 1331954415}
|
||||
- {fileID: 1097328752}
|
||||
7
Assets/Sample/UIToolkit/UTKToolBar.unity.meta
Normal file
7
Assets/Sample/UIToolkit/UTKToolBar.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 735821fd3c67e3f49a83cb87e5cf142e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
225
Assets/Sample/UIToolkit/UTKToolBarSample.cs
Normal file
225
Assets/Sample/UIToolkit/UTKToolBarSample.cs
Normal file
@@ -0,0 +1,225 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UVC.UIToolkit;
|
||||
using UVC.UI.Commands;
|
||||
using UVC.Log;
|
||||
|
||||
namespace UVC.Sample.UIToolkit
|
||||
{
|
||||
/// <summary>
|
||||
/// UTKToolBar 독립 실행 샘플 코드입니다.
|
||||
/// 가로/세로 배치 전환, 4가지 버튼 타입, 구분선을 데모합니다.
|
||||
/// </summary>
|
||||
public class UTKToolBarSample : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private UIDocument? _uiDocument;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("시작 시 적용할 테마")]
|
||||
private UTKTheme initialTheme = UTKTheme.Dark;
|
||||
|
||||
private UTKToggle? _themeToggle;
|
||||
private VisualElement? _root;
|
||||
private UTKToolBar? _horizontalToolBar;
|
||||
private UTKToolBar? _verticalToolBar;
|
||||
private UTKToolBarModel? _horizontalModel;
|
||||
private UTKToolBarModel? _verticalModel;
|
||||
private Label? _eventLabel;
|
||||
private readonly List<string> _eventLogs = new();
|
||||
private const int MaxLogLines = 8;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// UIDocument 참조 확인
|
||||
var doc = GetComponent<UIDocument>();
|
||||
if (doc == null)
|
||||
{
|
||||
Debug.LogError("UIDocument가 할당되지 않았습니다.");
|
||||
return;
|
||||
}
|
||||
_uiDocument = doc;
|
||||
_root = _uiDocument.rootVisualElement;
|
||||
|
||||
UTKThemeManager.Instance.RegisterRoot(_root);
|
||||
UTKThemeManager.Instance.SetTheme(initialTheme);
|
||||
|
||||
// 테마 토글
|
||||
_themeToggle = _root.Q<UTKToggle>("toggle");
|
||||
if (_themeToggle != null)
|
||||
{
|
||||
_themeToggle.OnValueChanged += (isOn) =>
|
||||
{
|
||||
UTKThemeManager.Instance.SetTheme(!isOn ? UTKTheme.Dark : UTKTheme.Light);
|
||||
};
|
||||
}
|
||||
|
||||
// 툴바 영역
|
||||
var toolbarArea = _root.Q<VisualElement>("toolbar-area");
|
||||
if (toolbarArea == null)
|
||||
{
|
||||
toolbarArea = new VisualElement();
|
||||
toolbarArea.style.flexDirection = FlexDirection.Column;
|
||||
toolbarArea.style.paddingTop = 8;
|
||||
toolbarArea.style.paddingLeft = 8;
|
||||
toolbarArea.style.paddingRight = 8;
|
||||
_root.Add(toolbarArea);
|
||||
}
|
||||
|
||||
// 이벤트 라벨
|
||||
_eventLabel = new Label("(버튼을 클릭하면 여기에 이벤트가 표시됩니다)");
|
||||
_eventLabel.style.fontSize = 11;
|
||||
_eventLabel.style.whiteSpace = WhiteSpace.Normal;
|
||||
_eventLabel.style.marginTop = 12;
|
||||
|
||||
CreateHorizontalToolBar(toolbarArea);
|
||||
CreateVerticalToolBar(toolbarArea);
|
||||
|
||||
toolbarArea.Add(_eventLabel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 가로 툴바를 생성합니다.
|
||||
/// </summary>
|
||||
private void CreateHorizontalToolBar(VisualElement parent)
|
||||
{
|
||||
var label = new Label("Horizontal Toolbar");
|
||||
label.style.fontSize = 14;
|
||||
label.style.marginTop = 8;
|
||||
label.style.marginBottom = 4;
|
||||
parent.Add(label);
|
||||
|
||||
_horizontalModel = new UTKToolBarModel();
|
||||
|
||||
// Standard
|
||||
_horizontalModel.AddStandardButton("저장", UTKMaterialIcons.Save, new DebugLogCommand("저장"), "파일 저장");
|
||||
_horizontalModel.AddStandardButton("실행 취소", UTKMaterialIcons.Undo, new DebugLogCommand("실행 취소"));
|
||||
_horizontalModel.AddStandardButton("다시 실행", UTKMaterialIcons.Redo, new DebugLogCommand("다시 실행"));
|
||||
|
||||
_horizontalModel.AddSeparator();
|
||||
|
||||
// Toggle
|
||||
_horizontalModel.AddToggleButton("그리드", false, UTKMaterialIcons.GridOn, UTKMaterialIcons.GridOff, tooltip: "그리드 표시/숨김");
|
||||
_horizontalModel.AddToggleButton("스냅", false, UTKMaterialIcons.FilterCenterFocus, UTKMaterialIcons.CenterFocusWeak, tooltip: "스냅 활성화");
|
||||
|
||||
_horizontalModel.AddSeparator();
|
||||
|
||||
// Radio
|
||||
_horizontalModel.AddRadioButton("tool", "선택", true, UTKMaterialIcons.NearMe, tooltip: "선택 도구");
|
||||
_horizontalModel.AddRadioButton("tool", "이동", false, UTKMaterialIcons.OpenWith, tooltip: "이동 도구");
|
||||
_horizontalModel.AddRadioButton("tool", "회전", false, UTKMaterialIcons.Refresh, tooltip: "회전 도구");
|
||||
|
||||
_horizontalModel.AddSeparator();
|
||||
|
||||
// Expandable
|
||||
var shapeBtn = _horizontalModel.AddExpandableButton("도형", UTKMaterialIcons.Category, tooltip: "도형 추가", updateIconOnSelection: true);
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "사각형", IconPath = UTKMaterialIcons.CropSquare, UseMaterialIcon = true });
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "원형", IconPath = UTKMaterialIcons.Circle, UseMaterialIcon = true });
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "삼각형", IconPath = UTKMaterialIcons.ChangeHistory, UseMaterialIcon = true });
|
||||
|
||||
_horizontalToolBar = new UTKToolBar();
|
||||
_horizontalToolBar.Orientation = UTKToolBarOrientation.Horizontal;
|
||||
_horizontalToolBar.OnAction += OnToolBarAction;
|
||||
_horizontalToolBar.BuildToolBar(_horizontalModel);
|
||||
|
||||
parent.Add(_horizontalToolBar);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 세로 툴바를 생성합니다.
|
||||
/// </summary>
|
||||
private void CreateVerticalToolBar(VisualElement parent)
|
||||
{
|
||||
var label = new Label("Vertical Toolbar");
|
||||
label.style.fontSize = 14;
|
||||
label.style.marginTop = 12;
|
||||
label.style.marginBottom = 4;
|
||||
parent.Add(label);
|
||||
|
||||
_verticalModel = new UTKToolBarModel();
|
||||
|
||||
_verticalModel.AddStandardButton("", UTKMaterialIcons.Save, new DebugLogCommand("세로: 저장"), "저장");
|
||||
_verticalModel.AddStandardButton("", UTKMaterialIcons.Undo, new DebugLogCommand("세로: 실행 취소"), "실행 취소");
|
||||
|
||||
_verticalModel.AddSeparator();
|
||||
|
||||
_verticalModel.AddToggleButton("", false, UTKMaterialIcons.Visibility, UTKMaterialIcons.VisibilityOff, tooltip: "표시/숨김");
|
||||
_verticalModel.AddToggleButton("", false, UTKMaterialIcons.Lock, UTKMaterialIcons.LockOpen, tooltip: "잠금/해제");
|
||||
|
||||
_verticalModel.AddSeparator();
|
||||
|
||||
_verticalModel.AddRadioButton("vtool", "", true, UTKMaterialIcons.NearMe, tooltip: "선택 도구");
|
||||
_verticalModel.AddRadioButton("vtool", "", false, UTKMaterialIcons.OpenWith, tooltip: "이동 도구");
|
||||
_verticalModel.AddRadioButton("vtool", "", false, UTKMaterialIcons.Refresh, tooltip: "회전 도구");
|
||||
|
||||
_verticalModel.AddSeparator();
|
||||
|
||||
// Expandable
|
||||
var shapeBtn = _verticalModel.AddExpandableButton("", UTKMaterialIcons.Category, tooltip: "도형 추가", updateIconOnSelection: true);
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "사각형", IconPath = UTKMaterialIcons.CropSquare, UseMaterialIcon = true });
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "원형", IconPath = UTKMaterialIcons.Circle, UseMaterialIcon = true });
|
||||
shapeBtn.SubButtons.Add(new UTKToolBarStandardButtonData { Text = "삼각형", IconPath = UTKMaterialIcons.ChangeHistory, UseMaterialIcon = true });
|
||||
|
||||
_verticalToolBar = new UTKToolBar();
|
||||
_verticalToolBar.Orientation = UTKToolBarOrientation.Vertical;
|
||||
_verticalToolBar.OnAction += OnToolBarAction;
|
||||
_verticalToolBar.BuildToolBar(_verticalModel);
|
||||
|
||||
parent.Add(_verticalToolBar);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 툴바 액션 이벤트 핸들러
|
||||
/// </summary>
|
||||
private void OnToolBarAction(UTKToolBarActionEventArgs args)
|
||||
{
|
||||
string valueStr = args.Value != null ? args.Value.ToString() ?? "" : "null";
|
||||
string logEntry = $"[{args.ActionType}] {args.Text}: {valueStr}";
|
||||
ULog.Debug($"[UTKToolBar Sample] {logEntry}");
|
||||
AppendLog(logEntry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 이벤트 로그에 항목을 추가합니다.
|
||||
/// </summary>
|
||||
private void AppendLog(string message)
|
||||
{
|
||||
_eventLogs.Add(message);
|
||||
while (_eventLogs.Count > MaxLogLines)
|
||||
{
|
||||
_eventLogs.RemoveAt(0);
|
||||
}
|
||||
if (_eventLabel != null)
|
||||
{
|
||||
_eventLabel.text = string.Join("\n", _eventLogs);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_horizontalToolBar != null)
|
||||
{
|
||||
_horizontalToolBar.OnAction -= OnToolBarAction;
|
||||
_horizontalToolBar.Dispose();
|
||||
_horizontalToolBar = null;
|
||||
}
|
||||
|
||||
if (_verticalToolBar != null)
|
||||
{
|
||||
_verticalToolBar.OnAction -= OnToolBarAction;
|
||||
_verticalToolBar.Dispose();
|
||||
_verticalToolBar = null;
|
||||
}
|
||||
|
||||
_horizontalModel?.Dispose();
|
||||
_horizontalModel = null;
|
||||
_verticalModel?.Dispose();
|
||||
_verticalModel = null;
|
||||
|
||||
_eventLogs.Clear();
|
||||
|
||||
ULog.Debug("UTKToolBarSample 정리 완료");
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Sample/UIToolkit/UTKToolBarSample.cs.meta
Normal file
2
Assets/Sample/UIToolkit/UTKToolBarSample.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39265a781c40bdb4a90aa56b0fbf44a6
|
||||
6
Assets/Sample/UIToolkit/UTKToolBarUXML.uxml
Normal file
6
Assets/Sample/UIToolkit/UTKToolBarUXML.uxml
Normal file
@@ -0,0 +1,6 @@
|
||||
<UXML xmlns="UnityEngine.UIElements" xmlns:utk="UVC.UIToolkit" editor-extension-mode="False">
|
||||
<VisualElement style="width: 100%; height: 100%; flex-direction: column;">
|
||||
<VisualElement name="toolbar-area" style="flex-grow: 1; flex-direction: column; padding: 8px;" />
|
||||
<utk:UTKToggle name="toggle" label="테마 변경" style="position: absolute; top: 8px; right: 10px; z-index: 10;" />
|
||||
</VisualElement>
|
||||
</UXML>
|
||||
10
Assets/Sample/UIToolkit/UTKToolBarUXML.uxml.meta
Normal file
10
Assets/Sample/UIToolkit/UTKToolBarUXML.uxml.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54e4f33c8b08cb54f97dbdb5edd79e1e
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
Reference in New Issue
Block a user