A RadioButton lets you select a single choice when used along with other RadioButtons in a group. You can use a GroupBox to group RadioButtons. Otherwise, the panel acts as the default group.
UI Builder, UXML, C#으로 RadioButton을 생성할 수 있습니다. 다음 C# 예시에서는 동일한 컨테이너에 두 개의 새로운 라디오 버튼을 생성하고 패널에서 논리적으로 그룹화합니다.
var choice1 = new RadioButton() { text = "Choice 1" };
choice1.RegisterValueChangedCallback(v => Debug.Log("Choice 1 is :" + v.newValue));
var choice2 = new RadioButton() { text = "Choice 2" };
choice2.RegisterValueChangedCallback(v => Debug.Log("Choice 2 is :" + v.newValue));
container.Add(choice1);
container.Add(choice2);
다음 UXML 예시에서는 RadioButton을 생성합니다.
[!code-xml[(External/Resources/editor_resources/Assets/Editor Default Resources/UIPackageResources/Snippets/UXML/RadioButtonSnippet.uxml)]
다음 C# 예시에서는 커스터마이즈 가능한 일부 RadioButton 기능을 보여 줍니다.
[!code-cs[(Modules/UIElementsSamplesEditor/Snippets/RadioButtonSnippet.cs#sample)]
이 예시를 Unity에서 실험해 보려면 Window > UI Toolkit > Samples로 이동합니다.
C# 클래스:RadioButton
네임스페이스:UnityEngine.UIElements
기본 클래스:BaseBoolField
이 요소는 다음 속성을 해당 기본 클래스에서 상속합니다.
Name | 타입 | 설명 |
---|---|---|
binding-path |
string |
바인드될 타겟 프로퍼티의 경로입니다. |
focusable |
boolean |
요소에 포커스를 맞출 수 있으면 true입니다. |
label |
string |
필드 옆에 표시될 레이블을 나타내는 문자열입니다. |
tabindex |
int |
포커스 링에서 포커스를 맞출 수 있는 항목을 정렬하는 데 사용되는 정수입니다.0보다 크거나 같아야 합니다. |
text |
string |
BaseBoolField 뒤에 표시되는 선택적 텍스트입니다. Unity는 Label 이 존재하지 않는 경우 자동으로 생성합니다. |
value |
boolean |
필드와 연결된 값입니다. |
또한 이 요소는 다음 속성을 VisualElement
에서 상속합니다.
Name | 타입 | 설명 |
---|---|---|
content-container |
string |
자식 요소가 추가되며, 일반적으로 요소 자체와 동일합니다. |
name |
string |
이 VisualElement의 이름입니다. 이 프로퍼티를 사용하면 특정 요소를 타게팅하는 USS 선택자를 작성할 수 있습니다.요소에 고유한 이름을 부여하는 것이 표준 관행입니다. |
picking-mode |
UIElements.PickingMode |
mouseEvents 또는 IPanel.Pick 쿼리 중에 이 요소를 선택할 수 있는지를 결정합니다. |
style |
string |
이 요소의 스타일 오브젝트에 대한 레퍼런스입니다. USS 파일에서 계산된 데이터 또는 C#에서 이 오브젝트에 작성된 인라인 스타일을 포함합니다. |
tooltip |
string |
사용자가 마우스를 요소 위에 잠시 놓은 후 정보 박스 안에 표시할 텍스트입니다.이는 에디터 UI에서만 지원됩니다. |
usage-hints |
UIElements.UsageHints |
VisualElement 에 대한 고수준의 의도된 사용 패턴을 지정하는 힌트 값 조합입니다.이 프로퍼티는 VisualElement 가 아직 Panel 에 포함되어 있지 않을 때만 설정할 수 있습니다.Panel 에 포함되면 이 프로퍼티는 사실상 읽기 전용이 되며, 변경을 시도하면 예외가 발생합니다.적절한 UsageHints 를 지정하면 시스템에서 예상하는 사용 패턴에 따라 특정 작업을 처리하거나 가속하는 방법에 대해 더 나은 결정을 내릴 수 있습니다.이러한 힌트는 동작이나 시각적 결과에는 영향을 주지 않으며 패널과 그 안의 요소의 전반적인 성능에만 영향을 줍니다.항상 적절한 UsageHints 를 지정하는 것이 좋지만, 일부 UsageHints 는 특정 조건(예: 타겟 플랫폼의 하드웨어 제한으로 인해)에서 내부적으로 무시될 수 있다는 점에 유의하십시오. |
view-data-key |
string |
보기 데이터 지속성에 사용됩니다(예: 트리 확장 상태, 스크롤 포지션, 줌 레벨). 이는 보기 데이터 스토어의 보기 데이터를 저장/로드하는 데 사용되는 키입니다.이 키를 설정하지 않으면 이 VisualElement 에 대한 지속성이 비활성화됩니다. |
다음 표는 모든 C# 공용 프로퍼티 이름과 관련 USS 선택자의 리스트입니다.
C# 프로퍼티 | USS 선택자 | 설명 |
---|---|---|
ussClassName |
.unity-radio-button |
RadioButton 요소의 USS 클래스명입니다. Unity는 이 USS 클래스를 RadioButton 요소의 모든 인스턴스에 추가합니다.이 클래스에 적용된 모든 스타일링은 시각적 트리의 스타일시트 옆이나 아래에 있는 모든 RadioButton에 영향을 줍니다. |
labelUssClassName |
.unity-radio-button__label |
RadioButton 요소에 있는 레이블의 USS 클래스명입니다. Unity는 RadioButton에 레이블이 있는 경우 RadioButton 의 Label 하위 요소에 이 USS 클래스를 추가합니다. |
inputUssClassName |
.unity-radio-button__input |
RadioButton 요소에 있는 입력 요소의 USS 클래스명입니다. Unity는 이 USS 클래스를 RadioButton 의 입력 하위 요소에 추가합니다.입력 하위 요소는 매니퓰레이터에 리스폰스를 제공합니다. |
checkmarkBackgroundUssClassName |
.unity-radio-button__checkmark-background |
RadioButton 요소에 있는 체크마크 배경의 USS 클래스명입니다. Unity는 이 USS 클래스를 RadioButton 의 체크마크 배경 하위 요소에 추가합니다. |
checkmarkUssClassName |
.unity-radio-button__checkmark |
RadioButton 요소에 있는 체크마크의 USS 클래스명입니다. Unity는 이 USS 클래스를 RadioButton 의 체크마크 하위 요소에 추가합니다. |
textUssClassName |
.unity-radio-button__text |
RadioButton 요소에 있는 텍스트 요소의 USS 클래스명입니다. Unity는 이 USS 클래스를 RadioButton 의 텍스트 하위 요소에 추가합니다. |
ussClassName |
.unity-base-field |
이 타입 요소의 USS 클래스명입니다. |
labelUssClassName |
.unity-base-field__label |
이 타입의 요소에 있는 레이블의 USS 클래스명입니다. |
inputUssClassName |
.unity-base-field__input |
이 타입의 요소에 있는 입력 요소의 USS 클래스명입니다. |
noLabelVariantUssClassName |
.unity-base-field--no-label |
레이블이 없는 경우 이 타입 요소의 USS 클래스명입니다. |
labelDraggerVariantUssClassName |
.unity-base-field__label--with-dragger |
연결된 드래거가 있는 경우 이 타입의 요소에 있는 레이블의 USS 클래스명입니다. |
mixedValueLabelUssClassName |
.unity-base-field__label--mixed-value |
혼합된 값을 표시하는 요소의 USS 클래스명입니다. |
alignedFieldUssClassName |
.unity-base-field__aligned |
인스펙터 요소에 정렬된 요소의 USS 클래스명입니다. |
disabledUssClassName |
.unity-disabled |
비활성화된 로컬 요소의 USS 클래스명입니다. |
또한 인스펙터 또는 UI 툴킷 디버거의 매칭 선택자 섹션을 사용하여 해당 계층 구조의 모든 레벨에서 VisualElement
컴포넌트에 영향을 주는 USS 선택자를 확인할 수도 있습니다.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.