460 lines
20 KiB
C#
460 lines
20 KiB
C#
#nullable enable
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using Cysharp.Threading.Tasks;
|
||
using UnityEngine;
|
||
using UnityEngine.UIElements;
|
||
using UVC.UIToolkit;
|
||
|
||
/// <summary>
|
||
/// UTKStyleGuideSample의 Window 카테고리 Initialize 메서드들
|
||
/// </summary>
|
||
public partial class UTKStyleGuideSample
|
||
{
|
||
#region Window Initializers
|
||
|
||
private void InitializeAccordionListWindowSample(VisualElement root)
|
||
{
|
||
var container = root.Q<VisualElement>("accordion-list-window-container");
|
||
if (container == null) return;
|
||
|
||
var accordionWindow = new UTKAccordionListWindow();
|
||
accordionWindow.Title = "프리팹 라이브러리";
|
||
accordionWindow.ShowCloseButton = true;
|
||
|
||
var data = new UTKAccordionData();
|
||
|
||
// ========================================
|
||
// 수평 레이아웃 섹션 1: Settings
|
||
// ========================================
|
||
var settingsSection = new UTKAccordionSectionData
|
||
{
|
||
Title = "Settings",
|
||
IsExpanded = true,
|
||
LayoutType = UTKAccordionLayoutType.Horizontal,
|
||
HorizontalItems = new List<UTKAccordionHorizontalItemData>
|
||
{
|
||
new UTKAccordionHorizontalItemData
|
||
{
|
||
Head = UTKAccordionContentSpec.FromImage(UTKMaterialIcons.LibraryAdd),
|
||
Content = UTKAccordionContentSpec.FromText("Graphics", "open_graphics"),
|
||
Tail = new List<UTKAccordionContentSpec>
|
||
{
|
||
UTKAccordionContentSpec.FromIconButton(UTKMaterialIcons.Refresh, 12, "refresh_graphics", "새로고침"),
|
||
UTKAccordionContentSpec.FromIconButton(UTKMaterialIcons.Settings, 12, "setting_graphics", "설정"),
|
||
}
|
||
},
|
||
new UTKAccordionHorizontalItemData
|
||
{
|
||
Head = UTKAccordionContentSpec.FromImage(UTKMaterialIcons.AudioFile),
|
||
Content = UTKAccordionContentSpec.FromText("Audio", "open_audio"),
|
||
Tail = new List<UTKAccordionContentSpec>
|
||
{
|
||
UTKAccordionContentSpec.FromIconButton(UTKMaterialIcons.Refresh, 12, "refresh_audio", "새로고침"),
|
||
UTKAccordionContentSpec.FromIconButton(UTKMaterialIcons.Settings, 12, "setting_audio", "설정"),
|
||
}
|
||
},
|
||
new UTKAccordionHorizontalItemData
|
||
{
|
||
Head = UTKAccordionContentSpec.FromImage(UTKMaterialIcons.Explore),
|
||
Content = UTKAccordionContentSpec.FromText("Network", "open_network"),
|
||
Tail = new List<UTKAccordionContentSpec>
|
||
{
|
||
UTKAccordionContentSpec.FromIconButton(UTKMaterialIcons.Refresh, 12, "refresh_network", "새로고침"),
|
||
}
|
||
}
|
||
}
|
||
};
|
||
data.Sections.Add(settingsSection);
|
||
|
||
// ========================================
|
||
// 수평 레이아웃 섹션 2: Components
|
||
// ========================================
|
||
var componentsSection = new UTKAccordionSectionData
|
||
{
|
||
Title = "Components",
|
||
IsExpanded = false,
|
||
LayoutType = UTKAccordionLayoutType.Horizontal,
|
||
HorizontalItems = new List<UTKAccordionHorizontalItemData>
|
||
{
|
||
new UTKAccordionHorizontalItemData
|
||
{
|
||
Content = UTKAccordionContentSpec.FromText("Transform", "open_transform"),
|
||
},
|
||
new UTKAccordionHorizontalItemData
|
||
{
|
||
Content = UTKAccordionContentSpec.FromText("Rigidbody", "open_rigidbody"),
|
||
},
|
||
new UTKAccordionHorizontalItemData
|
||
{
|
||
Content = UTKAccordionContentSpec.FromText("Collider", "open_collider"),
|
||
}
|
||
}
|
||
};
|
||
data.Sections.Add(componentsSection);
|
||
|
||
// ========================================
|
||
// 그리드 레이아웃 섹션 1: Vehicles
|
||
// ========================================
|
||
var vehiclesSection = new UTKAccordionSectionData
|
||
{
|
||
Title = "Vehicles",
|
||
IsExpanded = true,
|
||
LayoutType = UTKAccordionLayoutType.Grid,
|
||
GridItems = new List<UTKAccordionGridItemData>
|
||
{
|
||
new UTKAccordionGridItemData
|
||
{
|
||
Caption = "Forklift",
|
||
ImagePath = "Simulator/Images/lib_forklift_400x300",
|
||
PrefabPath = "Simulator/FreeForkLift/Prefabs/Forklift",
|
||
Tag = "vehicle"
|
||
},
|
||
new UTKAccordionGridItemData
|
||
{
|
||
Caption = "Truck",
|
||
ImagePath = "Simulator/Images/lib_forklift_400x300",
|
||
PrefabPath = "Simulator/FreeForkLift/Prefabs/Forklift",
|
||
Tag = "vehicle"
|
||
}
|
||
}
|
||
};
|
||
data.Sections.Add(vehiclesSection);
|
||
|
||
// ========================================
|
||
// 그리드 레이아웃 섹션 2: Objects
|
||
// ========================================
|
||
var objectsSection = new UTKAccordionSectionData
|
||
{
|
||
Title = "Objects",
|
||
IsExpanded = true,
|
||
LayoutType = UTKAccordionLayoutType.Grid,
|
||
GridItems = new List<UTKAccordionGridItemData>
|
||
{
|
||
new UTKAccordionGridItemData
|
||
{
|
||
Caption = "Pallet",
|
||
ImagePath = "Simulator/Images/lib_pallet_400x300",
|
||
PrefabPath = "Simulator/FreeForkLift/Prefabs/PalletEmpty",
|
||
Tag = "object"
|
||
},
|
||
new UTKAccordionGridItemData
|
||
{
|
||
Caption = "Pallet (Full)",
|
||
ImagePath = "Simulator/Images/lib_pallet_400x300",
|
||
PrefabPath = "Simulator/FreeForkLift/Prefabs/PalletEmpty",
|
||
Tag = "object"
|
||
},
|
||
new UTKAccordionGridItemData
|
||
{
|
||
Caption = "Box",
|
||
ImagePath = "Simulator/Images/lib_pallet_400x300",
|
||
PrefabPath = "Simulator/FreeForkLift/Prefabs/PalletEmpty",
|
||
Tag = "object"
|
||
}
|
||
}
|
||
};
|
||
data.Sections.Add(objectsSection);
|
||
|
||
// ========================================
|
||
// 그리드 레이아웃 섹션 3: Characters
|
||
// ========================================
|
||
var charactersSection = new UTKAccordionSectionData
|
||
{
|
||
Title = "Characters",
|
||
IsExpanded = true,
|
||
LayoutType = UTKAccordionLayoutType.Grid,
|
||
GridItems = new List<UTKAccordionGridItemData>
|
||
{
|
||
new UTKAccordionGridItemData
|
||
{
|
||
Caption = "Worker",
|
||
ImagePath = "Simulator/Images/lib_worker_400x300",
|
||
PrefabPath = "Simulator/CharCrafter – Free Preset Characters Pack (Vol. 1)/Prefabs/Male Young Guy",
|
||
Tag = "character"
|
||
},
|
||
new UTKAccordionGridItemData
|
||
{
|
||
Caption = "Manager",
|
||
ImagePath = "Simulator/Images/lib_worker_400x300",
|
||
PrefabPath = "Simulator/CharCrafter – Free Preset Characters Pack (Vol. 1)/Prefabs/Male Young Guy",
|
||
Tag = "character"
|
||
}
|
||
}
|
||
};
|
||
data.Sections.Add(charactersSection);
|
||
accordionWindow.SetData(data);
|
||
accordionWindow.Show();
|
||
|
||
container.Add(accordionWindow);
|
||
|
||
SetCodeSamples(root,
|
||
csharpCode: @"// 아코디언 리스트 윈도우 생성
|
||
var accordionWindow = new UTKAccordionListWindow();
|
||
accordionWindow.Title = ""프리펍 라이브러리"";
|
||
accordionWindow.ShowCloseButton = true;
|
||
|
||
var data = new UTKAccordionData();
|
||
|
||
// 수평 레이아웃 섹션
|
||
var settingsSection = new UTKAccordionSectionData
|
||
{
|
||
Title = ""Settings"",
|
||
IsExpanded = true,
|
||
LayoutType = UTKAccordionLayoutType.Horizontal,
|
||
HorizontalItems = new List<UTKAccordionHorizontalItemData>
|
||
{
|
||
new UTKAccordionHorizontalItemData
|
||
{
|
||
Head = UTKAccordionContentSpec.FromImage(UTKMaterialIcons.LibraryAdd),
|
||
Content = UTKAccordionContentSpec.FromText(""Graphics"", ""open_graphics""),
|
||
Tail = new List<UTKAccordionContentSpec>
|
||
{
|
||
UTKAccordionContentSpec.FromIconButton(UTKMaterialIcons.Refresh, 12, ""refresh_graphics"", ""새로고침""),
|
||
UTKAccordionContentSpec.FromIconButton(UTKMaterialIcons.Settings, 12, ""setting_graphics"", ""설정""),
|
||
}
|
||
}
|
||
}
|
||
};
|
||
data.Sections.Add(settingsSection);
|
||
|
||
// 그리드 레이아웃 섹션
|
||
var vehiclesSection = new UTKAccordionSectionData
|
||
{
|
||
Title = ""Vehicles"",
|
||
IsExpanded = true,
|
||
LayoutType = UTKAccordionLayoutType.Grid,
|
||
GridItems = new List<UTKAccordionGridItemData>
|
||
{
|
||
new UTKAccordionGridItemData
|
||
{
|
||
Caption = ""Forklift"",
|
||
ImagePath = ""Simulator/Images/lib_forklift_400x300"",
|
||
PrefabPath = ""Simulator/FreeForkLift/Prefabs/Forklift"",
|
||
Tag = ""vehicle""
|
||
}
|
||
}
|
||
};
|
||
data.Sections.Add(vehiclesSection);
|
||
|
||
accordionWindow.SetData(data);
|
||
accordionWindow.Show();");
|
||
}
|
||
|
||
private void InitializeComponentListWindowSample(VisualElement root)
|
||
{
|
||
var container = root.Q<VisualElement>("component-list-window-container");
|
||
if (container == null) return;
|
||
|
||
var componentWindow = new UTKComponentListWindow();
|
||
componentWindow.Title = "모델 리스트";
|
||
componentWindow.ShowCloseButton = true;
|
||
|
||
// 테마 변경 이벤트 구독
|
||
UTKThemeManager.Instance.OnThemeChanged += _ => UTKThemeManager.Instance.ApplyThemeToElement(componentWindow);
|
||
|
||
// 샘플 데이터
|
||
var category1 = new UTKComponentListCategoryData { name = "캐릭터", isExpanded = true };
|
||
category1.Add(new UTKComponentListItemData { name = "플레이어", ExternalKey = "player_001", IsVisible = true });
|
||
category1.Add(new UTKComponentListItemData { name = "NPC_01", ExternalKey = "npc_001", IsVisible = true });
|
||
category1.Add(new UTKComponentListItemData { name = "NPC_02", ExternalKey = "npc_002", IsVisible = false });
|
||
|
||
var category2 = new UTKComponentListCategoryData { name = "환경", isExpanded = false };
|
||
category2.Add(new UTKComponentListItemData { name = "나무", ExternalKey = "tree_001", IsVisible = true });
|
||
category2.Add(new UTKComponentListItemData { name = "바위", ExternalKey = "rock_001", IsVisible = true });
|
||
|
||
var data = new List<UTKComponentListItemDataBase> { category1, category2 };
|
||
componentWindow.SetData(data);
|
||
componentWindow.Show();
|
||
|
||
container.Add(componentWindow);
|
||
|
||
SetCodeSamples(root,
|
||
csharpCode: @"// 컴포넌트 리스트 윈도우 생성
|
||
var componentWindow = new UTKComponentListWindow();
|
||
componentWindow.Title = ""모델 리스트"";
|
||
componentWindow.ShowCloseButton = true;
|
||
|
||
// 테마 변경 이벤트 구독
|
||
UTKThemeManager.Instance.OnThemeChanged += _ => UTKThemeManager.Instance.ApplyThemeToElement(componentWindow);
|
||
|
||
// 샘플 데이터
|
||
var category1 = new UTKComponentListCategoryData { name = ""캐릭터"", isExpanded = true };
|
||
category1.Add(new UTKComponentListItemData { name = ""플레이어"", ExternalKey = ""player_001"", IsVisible = true });
|
||
category1.Add(new UTKComponentListItemData { name = ""NPC_01"", ExternalKey = ""npc_001"", IsVisible = true });
|
||
category1.Add(new UTKComponentListItemData { name = ""NPC_02"", ExternalKey = ""npc_002"", IsVisible = false });
|
||
|
||
var category2 = new UTKComponentListCategoryData { name = ""환경"", isExpanded = false };
|
||
category2.Add(new UTKComponentListItemData { name = ""나무"", ExternalKey = ""tree_001"", IsVisible = true });
|
||
category2.Add(new UTKComponentListItemData { name = ""바위"", ExternalKey = ""rock_001"", IsVisible = true });
|
||
|
||
var data = new List<UTKComponentListItemDataBase> { category1, category2 };
|
||
componentWindow.SetData(data);
|
||
componentWindow.Show();");
|
||
}
|
||
|
||
private void InitializeComponentTabListWindowSample(VisualElement root)
|
||
{
|
||
var container = root.Q<VisualElement>("component-tab-list-window-container");
|
||
if (container == null) return;
|
||
|
||
var tabWindow = new UTKComponentTabListWindow();
|
||
tabWindow.Title = "모델 라이브러리";
|
||
tabWindow.ShowCloseButton = true;
|
||
|
||
// 테마 변경 이벤트 구독
|
||
UTKThemeManager.Instance.OnThemeChanged += _ => UTKThemeManager.Instance.ApplyThemeToElement(tabWindow);
|
||
|
||
// 샘플 데이터 (카테고리가 탭으로 자동 생성됨)
|
||
var category1 = new UTKComponentListCategoryData { name = "캐릭터", isExpanded = true };
|
||
category1.Add(new UTKComponentListItemData { name = "플레이어", IsVisible = true });
|
||
category1.Add(new UTKComponentListItemData { name = "몬스터", IsVisible = true });
|
||
|
||
var category2 = new UTKComponentListCategoryData { name = "환경", isExpanded = true };
|
||
category2.Add(new UTKComponentListItemData { name = "나무", IsVisible = true });
|
||
category2.Add(new UTKComponentListItemData { name = "풀", IsVisible = true });
|
||
|
||
var category3 = new UTKComponentListCategoryData { name = "아이템", isExpanded = true };
|
||
category3.Add(new UTKComponentListItemData { name = "검", IsVisible = true });
|
||
category3.Add(new UTKComponentListItemData { name = "방패", IsVisible = true });
|
||
|
||
var data = new List<UTKComponentListItemDataBase> { category1, category2, category3 };
|
||
tabWindow.SetData(data);
|
||
tabWindow.Show();
|
||
|
||
container.Add(tabWindow);
|
||
|
||
SetCodeSamples(root,
|
||
csharpCode: @"// 컴포넌트 탭 리스트 윈도우 생성
|
||
var tabWindow = new UTKComponentTabListWindow();
|
||
tabWindow.Title = ""모델 라이브러리"";
|
||
tabWindow.ShowCloseButton = true;
|
||
|
||
// 테마 변경 이벤트 구독
|
||
UTKThemeManager.Instance.OnThemeChanged += _ => UTKThemeManager.Instance.ApplyThemeToElement(tabWindow);
|
||
|
||
// 샘플 데이터 (카테고리가 탭으로 자동 생성됨)
|
||
var category1 = new UTKComponentListCategoryData { name = ""캐릭터"", isExpanded = true };
|
||
category1.Add(new UTKComponentListItemData { name = ""플레이어"", IsVisible = true });
|
||
category1.Add(new UTKComponentListItemData { name = ""몬스터"", IsVisible = true });
|
||
|
||
var category2 = new UTKComponentListCategoryData { name = ""환경"", isExpanded = true };
|
||
category2.Add(new UTKComponentListItemData { name = ""나무"", IsVisible = true });
|
||
category2.Add(new UTKComponentListItemData { name = ""풀"", IsVisible = true });
|
||
|
||
var category3 = new UTKComponentListCategoryData { name = ""아이템"", isExpanded = true };
|
||
category3.Add(new UTKComponentListItemData { name = ""검"", IsVisible = true });
|
||
category3.Add(new UTKComponentListItemData { name = ""방패"", IsVisible = true });
|
||
|
||
var data = new List<UTKComponentListItemDataBase> { category1, category2, category3 };
|
||
tabWindow.SetData(data);
|
||
tabWindow.Show();");
|
||
}
|
||
|
||
private void InitializeImageListWindowSample(VisualElement root)
|
||
{
|
||
var container = root.Q<VisualElement>("image-list-window-container");
|
||
if (container == null) return;
|
||
|
||
var imageWindow = new UTKImageListWindow();
|
||
imageWindow.Title = "텍스처 라이브러리";
|
||
imageWindow.ShowCloseButton = true;
|
||
|
||
// 테마 변경 이벤트 구독
|
||
UTKThemeManager.Instance.OnThemeChanged += _ => UTKThemeManager.Instance.ApplyThemeToElement(imageWindow);
|
||
|
||
// 샘플 데이터
|
||
var data = new List<UTKImageListItemData>
|
||
{
|
||
new UTKImageListItemData { itemName = "Texture_01", externalId = "tex_001" },
|
||
new UTKImageListItemData { itemName = "Texture_02", externalId = "tex_002" },
|
||
new UTKImageListItemData { itemName = "Texture_03", externalId = "tex_003" },
|
||
new UTKImageListItemData { itemName = "Texture_04", externalId = "tex_004" }
|
||
};
|
||
imageWindow.SetData(data);
|
||
imageWindow.Show();
|
||
|
||
container.Add(imageWindow);
|
||
|
||
SetCodeSamples(root,
|
||
csharpCode: @"// 이미지 리스트 윈도우 생성
|
||
var imageWindow = new UTKImageListWindow();
|
||
imageWindow.Title = ""텍스처 라이브러리"";
|
||
imageWindow.ShowCloseButton = true;
|
||
|
||
// 테마 변경 이벤트 구독
|
||
UTKThemeManager.Instance.OnThemeChanged += _ => UTKThemeManager.Instance.ApplyThemeToElement(imageWindow);
|
||
|
||
// 샘플 데이터
|
||
var data = new List<UTKImageListItemData>
|
||
{
|
||
new UTKImageListItemData { itemName = ""Texture_01"", externalId = ""tex_001"" },
|
||
new UTKImageListItemData { itemName = ""Texture_02"", externalId = ""tex_002"" },
|
||
new UTKImageListItemData { itemName = ""Texture_03"", externalId = ""tex_003"" },
|
||
new UTKImageListItemData { itemName = ""Texture_04"", externalId = ""tex_004"" }
|
||
};
|
||
imageWindow.SetData(data);
|
||
imageWindow.Show();");
|
||
}
|
||
|
||
private void InitializeTreeListWindowSample(VisualElement root)
|
||
{
|
||
var container = root.Q<VisualElement>("tree-list-window-container");
|
||
if (container == null) return;
|
||
|
||
var treeWindow = new UTKTreeListWindow();
|
||
treeWindow.Title = "씬 계층 구조";
|
||
treeWindow.ShowCloseButton = true;
|
||
|
||
// 테마 변경 이벤트 구독
|
||
UTKThemeManager.Instance.OnThemeChanged += _ => UTKThemeManager.Instance.ApplyThemeToElement(treeWindow);
|
||
|
||
// 샘플 데이터
|
||
var environment = new UTKTreeListItemData { name = "Environment", isExpanded = true };
|
||
environment.Add(new UTKTreeListItemData { name = "Terrain", ExternalKey = "terrain_001", IsVisible = true });
|
||
environment.Add(new UTKTreeListItemData { name = "Trees", ExternalKey = "trees_001", IsVisible = true });
|
||
|
||
var characters = new UTKTreeListItemData { name = "Characters", isExpanded = false };
|
||
characters.Add(new UTKTreeListItemData { name = "Player", ExternalKey = "player_001", IsVisible = true });
|
||
characters.Add(new UTKTreeListItemData { name = "Enemies", ExternalKey = "enemies_001", IsVisible = true });
|
||
|
||
var rootNode = new UTKTreeListItemData { name = "Root", isExpanded = true };
|
||
rootNode.Add(environment);
|
||
rootNode.Add(characters);
|
||
|
||
var data = new List<UTKTreeListItemData> { rootNode };
|
||
treeWindow.SetData(data);
|
||
treeWindow.Show();
|
||
|
||
container.Add(treeWindow);
|
||
|
||
SetCodeSamples(root,
|
||
csharpCode: @"// 트리 리스트 윈도우 생성
|
||
var treeWindow = new UTKTreeListWindow();
|
||
treeWindow.Title = ""씬 계층 구조"";
|
||
treeWindow.ShowCloseButton = true;
|
||
|
||
// 테마 변경 이벤트 구독
|
||
UTKThemeManager.Instance.OnThemeChanged += _ => UTKThemeManager.Instance.ApplyThemeToElement(treeWindow);
|
||
|
||
// 샘플 데이터
|
||
var environment = new UTKTreeListItemData { name = ""Environment"", isExpanded = true };
|
||
environment.Add(new UTKTreeListItemData { name = ""Terrain"", ExternalKey = ""terrain_001"", IsVisible = true });
|
||
environment.Add(new UTKTreeListItemData { name = ""Trees"", ExternalKey = ""trees_001"", IsVisible = true });
|
||
|
||
var characters = new UTKTreeListItemData { name = ""Characters"", isExpanded = false };
|
||
characters.Add(new UTKTreeListItemData { name = ""Player"", ExternalKey = ""player_001"", IsVisible = true });
|
||
characters.Add(new UTKTreeListItemData { name = ""Enemies"", ExternalKey = ""enemies_001"", IsVisible = true });
|
||
|
||
var rootNode = new UTKTreeListItemData { name = ""Root"", isExpanded = true };
|
||
rootNode.Add(environment);
|
||
rootNode.Add(characters);
|
||
|
||
var data = new List<UTKTreeListItemData> { rootNode };
|
||
treeWindow.SetData(data);
|
||
treeWindow.Show();");
|
||
}
|
||
|
||
#endregion
|
||
}
|