Files
XRLib/Assets/Resources/UIToolkit/Sample/Button/UTKButtonSample.uxml
2026-01-21 20:43:54 +09:00

82 lines
6.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<UXML xmlns="UnityEngine.UIElements" xmlns:utk="UVC.UIToolkit">
<Style src="../UTKSampleCommon.uss" />
<Style src="UTKButtonSample.uss" />
<VisualElement class="utk-sample-container">
<!-- Description -->
<Label class="utk-sample-desc" text="다양한 스타일의 버튼 컴포넌트" />
<!-- Filled Buttons -->
<VisualElement class="utk-sample-section">
<Label class="utk-sample-section__title" text="Filled Buttons" />
<VisualElement class="utk-sample-row">
<utk:UTKButton name="btn-primary" text="Primary" variant="Primary" />
<utk:UTKButton name="btn-normal" text="Normal" variant="Normal" />
<utk:UTKButton name="btn-danger" text="Danger" variant="Danger" />
</VisualElement>
</VisualElement>
<!-- Outline Buttons -->
<VisualElement class="utk-sample-section">
<Label class="utk-sample-section__title" text="Outline Buttons" />
<VisualElement class="utk-sample-row">
<utk:UTKButton name="btn-outline-primary" text="Outline Primary" variant="OutlinePrimary" />
<utk:UTKButton name="btn-outline-normal" text="Outline Normal" variant="OutlineNormal" />
<utk:UTKButton name="btn-outline-danger" text="Outline Danger" variant="OutlineDanger" />
</VisualElement>
</VisualElement>
<!-- Icon Only -->
<VisualElement class="utk-sample-section">
<Label class="utk-sample-section__title" text="Icon Only" />
<VisualElement class="utk-sample-row" name="icon-only-row">
<!-- Icons will be set via C# code -->
</VisualElement>
</VisualElement>
<!-- Ghost -->
<VisualElement class="utk-sample-section">
<Label class="utk-sample-section__title" text="Ghost" />
<VisualElement class="utk-sample-row" name="ghost-row">
<utk:UTKButton name="btn-ghost" text="Ghost" variant="Ghost" />
<!-- Ghost icon button will be set via C# -->
</VisualElement>
</VisualElement>
<!-- Text -->
<VisualElement class="utk-sample-section">
<Label class="utk-sample-section__title" text="Text (Label/Icon Only)" />
<VisualElement class="utk-sample-row" name="text-row">
<utk:UTKButton name="btn-text-only" text="Text Only" variant="Text" />
<utk:UTKButton name="btn-text-link" text="Link Style" variant="Text" />
<!-- Text with icon will be set via C# -->
</VisualElement>
</VisualElement>
<!-- Text Icon Only (Circle) -->
<VisualElement class="utk-sample-section">
<Label class="utk-sample-section__title" text="Text Icon Only (Circle)" />
<VisualElement class="utk-sample-row" name="text-icon-only-row">
<!-- Circle icon buttons will be set via C# -->
</VisualElement>
</VisualElement>
<!-- Disabled -->
<VisualElement class="utk-sample-section">
<Label class="utk-sample-section__title" text="Disabled" />
<VisualElement class="utk-sample-row">
<utk:UTKButton name="btn-disabled-primary" text="Disabled" variant="Primary" is-enabled="false" />
<utk:UTKButton name="btn-disabled-normal" text="Disabled" variant="Normal" is-enabled="false" />
<utk:UTKButton name="btn-disabled-text" text="Disabled" variant="Text" is-enabled="false" />
</VisualElement>
</VisualElement>
<!-- Code Sample -->
<VisualElement class="utk-code-sample-container">
<utk:UTKCodeBlock title="C#" code="// 기본 버튼 생성&#10;var btn = new UTKButton(&quot;확인&quot;);&#10;btn.OnClicked += () =&gt; Debug.Log(&quot;클릭됨!&quot;);&#10;&#10;// 텍스트와 Material Icon이 있는 버튼&#10;var saveBtn = new UTKButton(&quot;저장&quot;, UTKMaterialIcons.Save, UTKButton.ButtonVariant.Primary);&#10;&#10;// 텍스트와 아이콘 (크기 지정)&#10;var largeIconBtn = new UTKButton(&quot;설정&quot;, UTKMaterialIcons.Settings, UTKButton.ButtonVariant.Primary, 28);&#10;var smallImageBtn = new UTKButton(&quot;닫기&quot;, UTKImageIcons.BtnClose22, UTKButton.ButtonVariant.Danger, 20);&#10;&#10;// Image Icon 설정&#10;var imgBtn = new UTKButton(&quot;닫기&quot;);&#10;imgBtn.SetImageIcon(UTKImageIcons.BtnClose22);&#10;imgBtn.SetImageIconByName(&quot;icon_setting_22&quot;);&#10;&#10;// 비동기 아이콘 설정&#10;await btn.SetMaterialIconAsync(UTKMaterialIcons.Search);&#10;await btn.SetImageIconAsync(UTKImageIcons.IconSetting22);&#10;&#10;// 아이콘만 표시하는 버튼&#10;var iconOnlyBtn = new UTKButton { IconOnly = true };&#10;iconOnlyBtn.SetMaterialIcon(UTKMaterialIcons.Close);&#10;&#10;// 버튼 스타일 변형&#10;btn.Variant = UTKButton.ButtonVariant.Primary;&#10;btn.Variant = UTKButton.ButtonVariant.Danger;&#10;btn.Variant = UTKButton.ButtonVariant.Ghost;&#10;&#10;// 버튼 크기&#10;btn.Size = UTKButton.ButtonSize.Small;&#10;btn.Size = UTKButton.ButtonSize.Large;&#10;&#10;// 아이콘 제거&#10;btn.ClearIcon();" />
<utk:UTKCodeBlock title="UXML" code="&lt;!-- 기본 버튼 --&gt;&#10;&lt;utk:UTKButton text=&quot;확인&quot; /&gt;&#10;&#10;&lt;!-- 버튼 변형 --&gt;&#10;&lt;utk:UTKButton text=&quot;저장&quot; variant=&quot;Primary&quot; /&gt;&#10;&lt;utk:UTKButton text=&quot;삭제&quot; variant=&quot;Danger&quot; /&gt;&#10;&lt;utk:UTKButton text=&quot;취소&quot; variant=&quot;Ghost&quot; /&gt;&#10;&lt;utk:UTKButton text=&quot;링크&quot; variant=&quot;Text&quot; /&gt;&#10;&#10;&lt;!-- 외곽선 변형 --&gt;&#10;&lt;utk:UTKButton text=&quot;확인&quot; variant=&quot;OutlinePrimary&quot; /&gt;&#10;&lt;utk:UTKButton text=&quot;삭제&quot; variant=&quot;OutlineDanger&quot; /&gt;&#10;&#10;&lt;!-- 크기 변형 --&gt;&#10;&lt;utk:UTKButton text=&quot;작은 버튼&quot; size=&quot;Small&quot; /&gt;&#10;&lt;utk:UTKButton text=&quot;큰 버튼&quot; size=&quot;Large&quot; /&gt;&#10;&#10;&lt;!-- 아이콘만 표시 --&gt;&#10;&lt;utk:UTKButton icon=&quot;&amp;#xe5cd;&quot; icon-only=&quot;true&quot; /&gt;&#10;&#10;&lt;!-- 비활성화 --&gt;&#10;&lt;utk:UTKButton text=&quot;비활성화&quot; is-enabled=&quot;false&quot; /&gt;&#10;&#10;&lt;!-- 외곽선 굵기 --&gt;&#10;&lt;utk:UTKButton text=&quot;두꺼운 외곽선&quot; border-width=&quot;2&quot; /&gt;" />
</VisualElement>
</VisualElement>
</UXML>