Files
XRLib/Assets/Resources/UIToolkit/Sample/Window/UTKComponentListWindowSample.uxml

21 lines
2.5 KiB
Plaintext
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<UXML xmlns="UnityEngine.UIElements" xmlns:utk="UVC.UIToolkit">
<Style src="../UTKSampleCommon.uss" />
<Style src="UTKWindowSample.uss" />
<VisualElement class="utk-sample-container">
<Label class="utk-sample-desc" text="컴포넌트 리스트를 윈도우 형태로 래핑한 컴포넌트입니다. 계층 구조(카테고리/아이템)와 가시성 토글, 검색 기능을 제공합니다." />
<VisualElement class="utk-sample-section">
<Label class="utk-sample-section__title" text="UTKComponentListWindow" />
<VisualElement name="component-list-window-container" class="utk-window-sample-container" />
</VisualElement>
<!-- Code Sample -->
<VisualElement class="utk-code-sample-container">
<utk:UTKCodeBlock title="C#" code="// 1. 윈도우 참조 획득&#10;var componentWindow = root.Q&lt;UTKComponentListWindow&gt;(&quot;component-window&quot;);&#10;&#10;// 2. 윈도우 제목 및 닫기 버튼 설정&#10;componentWindow.Title = &quot;모델 리스트&quot;;&#10;componentWindow.ShowCloseButton = true;&#10;&#10;// 3. 데이터 구성 - 카테고리와 아이템&#10;var data = new List&lt;UTKComponentListItemDataBase&gt;&#10;{&#10; new UTKComponentListCategoryData&#10; {&#10; name = &quot;캐릭터&quot;,&#10; isExpanded = true,&#10; children = new List&lt;UTKComponentListItemDataBase&gt;&#10; {&#10; new UTKComponentListItemData&#10; {&#10; name = &quot;플레이어&quot;,&#10; ExternalKey = &quot;player_001&quot;,&#10; IsVisible = true&#10; }&#10; }&#10; }&#10;};&#10;componentWindow.SetData(data);&#10;&#10;// 4. 선택 이벤트&#10;componentWindow.OnItemSelected = (items) =&gt;&#10;{&#10; foreach (var item in items)&#10; Debug.Log($&quot;선택됨: {item.name}&quot;);&#10;};&#10;&#10;// 5. 가시성 변경 이벤트 (눈 아이콘)&#10;componentWindow.OnItemVisibilityChanged += (item, isVisible) =&gt;&#10;{&#10; FindGameObject(item.ExternalKey)?.SetActive(isVisible);&#10;};&#10;&#10;// 6. 삭제 이벤트 (Delete 키)&#10;componentWindow.EnabledDeleteItem = true;&#10;componentWindow.OnItemDeleted = (item) =&gt;&#10;{&#10; componentWindow.DeleteItem(item);&#10;};&#10;&#10;// 7. 윈도우 표시&#10;componentWindow.Show();" />
<utk:UTKCodeBlock title="UXML" code="&lt;utk:UTKComponentListWindow name=&quot;component-window&quot; /&gt;" />
</VisualElement>
</VisualElement>
</UXML>