Files
XRLib/Assets/Resources/UIToolkit/Sample/Window/UTKTreeListWindowSample.uxml
2026-01-22 20:12:22 +09:00

21 lines
2.7 KiB
XML

<?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="UTKTreeListWindow" />
<VisualElement name="tree-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 treeWindow = root.Q&lt;UTKTreeListWindow&gt;(&quot;tree-window&quot;);&#10;&#10;// 2. 윈도우 제목 설정&#10;treeWindow.Title = &quot;씬 계층 구조&quot;;&#10;treeWindow.ShowCloseButton = true;&#10;&#10;// 3. 트리 데이터 구성&#10;var data = new List&lt;UTKTreeListItemData&gt;&#10;{&#10; new UTKTreeListItemData&#10; {&#10; name = &quot;Root&quot;,&#10; isExpanded = true,&#10; children = new List&lt;UTKTreeListItemData&gt;&#10; {&#10; new UTKTreeListItemData&#10; {&#10; name = &quot;Child 1&quot;,&#10; ExternalKey = &quot;obj_001&quot;,&#10; IsVisible = true&#10; },&#10; new UTKTreeListItemData&#10; {&#10; name = &quot;Child 2&quot;,&#10; children = new List&lt;UTKTreeListItemData&gt;&#10; {&#10; new UTKTreeListItemData { name = &quot;Grandchild&quot; }&#10; }&#10; }&#10; }&#10; }&#10;};&#10;treeWindow.SetData(data);&#10;&#10;// 4. 선택 이벤트&#10;treeWindow.OnItemSelected = (items) =&gt;&#10;{&#10; foreach (var item in items)&#10; HighlightGameObject(item.ExternalKey);&#10;};&#10;&#10;// 5. 가시성 변경 이벤트&#10;treeWindow.OnItemVisibilityChanged += (item, isVisible) =&gt;&#10;{&#10; FindGameObject(item.ExternalKey)?.SetActive(isVisible);&#10;};&#10;&#10;// 6. 삭제 이벤트&#10;treeWindow.EnabledDeleteItem = true;&#10;treeWindow.OnItemDeleted = (item) =&gt;&#10;{&#10; treeWindow.DeleteItem(item);&#10;};&#10;&#10;// 7. 프로그래밍 방식 선택&#10;treeWindow.SelectByItemId(itemId);&#10;treeWindow.ClearSelection();" />
<utk:UTKCodeBlock title="UXML" code="&lt;utk:UTKTreeListWindow name=&quot;tree-window&quot; /&gt;" />
</VisualElement>
</VisualElement>
</UXML>