다음은 ’PropertyField’에서 지원하는 데이터 타입 전환 및 필드에 대해 설명합니다.
UI 툴킷에 내장된 대부분의 컨트롤은 특정 데이터 타입에 대해 INotifyValueChanged
인터페이스를 구현합니다.예를 들어, DoubleField
는 INotifyValueChanged<Double>
을 구현하므로 DoubleField
컨트롤을 double
타입의 프로퍼티에 바인딩할 수 있습니다.바인딩 시스템으로 더 많은 데이터 타입을 바인딩할 수 있습니다.예를 들어 int
타입의 프로퍼티를 DoubleField
에 바인딩할 수 있습니다.
다음 표에는 바인딩할 수 있는 소스 및 타겟 데이터 타입이 나열되어 있습니다.
소스 데이터 타입 | INotifyValueChanged 의 타겟 데이터 타입 |
---|---|
long |
|
int |
|
double |
|
float |
|
char |
|
참고:데이터 손실을 방지하려면 PropertyField
를 사용하거나 아래의 PropertyField 표에서 지원하는 필드에 표시된 대로 적절한 데이터 타입을 사용하십시오.
PropertyField
에서 지원하는 필드인스펙터 창이 채워질 때 특정 타입에 대한 커스텀 에디터가 존재하지 않으면 바인딩 시스템은 InspectorElement.FillDefaultInspector()
를 호출합니다.그러면 SerializedObject
의 각 SerializedProperty
](../ScriptReference/SerializedProperty.html)에 대해 PropertyField
가 생성됩니다.
각 PropertyField
에는 그 아래에 int
를 나타내는 IntegerField
또는 bool
을 나타내는 Toggle
과 같은 매칭되는 컨트롤이 있습니다.프로퍼티에 하위 프로퍼티가 있는 경우, PropertyField
에는 Foldout
컨트롤이 있습니다.해당 Foldout
에는 각 하위 프로퍼티에 대해 적절한 기본 컨트롤이 있습니다.프로퍼티에 대한 커스텀 ’PropertyDrawer’를 생성한 경우, ’PropertyDrawer’의 ’CreatePropertyGUI()` 메서드에서 반환된 시각적 트리가 대신 사용됩니다.
참고:커스텀 UI를 만들 때 특정 컨트롤을 찾을 수 없는 경우가 아니라면 PropertyField
를 사용하지 마십시오.예를 들어 시각적 트리에서 컨트롤을 만들고 Color
에 바인딩하려면 PropertyField
가 아닌 ColorField
를 사용하십시오.이렇게 하면 시각적 트리가 더 가벼워지고 작업 속도가 빨라집니다.
다음 표에는 PropertyField
에서 지원하는 필드와 해당 데이터 타입이 나열되어 있습니다.
필드 | 데이터 타입 |
---|---|
BoundsField |
Bounds |
BoundsIntField |
BoundsInt |
ColorField |
색상 |
CurveField |
AnimationCurve |
FloatField |
float |
GradientField |
그레디언트 |
Hash128Field |
Hash128 |
IntegerField |
int |
IntegerField |
int, for the ArraySize |
LayerMaskField |
unit |
LongField |
long |
ObjectField |
UnityEngine.Object |
PopupField <string> |
열거형 |
RectField |
Rect |
RectIntField |
RectInt |
TextField |
문자열 |
TextField , with a maxLength=1 |
char |
Toggle |
bool |
Vector2Field |
Vector2 |
Vector2IntField |
Vector2Int |
Vector3Field |
Vector3 |
Vector3IntField |
Vector3Int |
Vector4Field |
Vector4 |
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.