USS를 사용할 때 UI 코드에서 빌트인 VisualElement
프로퍼티 또는 커스텀 프로퍼티에 대한 값을 지정할 수 있습니다.
USS 파일에서 값을 읽는 것 외에도 빌트인 프로퍼티 값은 VisualElement
의 C# 프로퍼티를 사용하여 C#으로 할당할 수 있습니다. C#으로 할당한 값은 Unity 스타일시트(USS)의 값을 오버라이드합니다.
커스텀 프로퍼티 API를 사용하여 USS를 확장할 수 있습니다.
이 섹션에는 지원되는 타입이 나와 있습니다.
다음 키워드에는 특별한 의미가 있습니다.
auto
inherit
unset
true
false
none
제한사항: auto
, inherit
및 unset
키워드는 올바르게 임포트되지만 런타임 시점에 지원되지 않습니다.
UIElements는 단위를 지원하지 않습니다. 모든 프로퍼티 타입은 픽셀 단위로 지정되었다고 간주됩니다.
숫자 값은 부동 소수점 또는 정수 리터럴입니다(예: flex:1.0
또는 width:200
). 숫자 값은 정수 리터럴을 포함한 부동 소수점으로 저장됩니다.
열거형은 열거형 기반 빌트인 프로퍼티에 대해서만 지원됩니다. 열거형은 숫자가 아니라 읽을 수 있는 이름을 제공합니다(예: position-type:absolute
).
UIElements는 다음의 리터럴 컬러 값 및 함수를 지원합니다.
#FFFF00
(채널당 rgba 1바이트), #0F0
(rgb)rgb(255, 255, 0)
rgba(255, 255, 0, 1.0)
hsl(0, 100%, 50%)
resource()
또는 url()
함수 중 하나를 사용하여 에셋을 참조할 수 있습니다. 예를 들어 background-image: resource("Images/img.png")
를 지정하면 Images
디렉토리에 img.png
를 배경 이미지로 지정할 수 있습니다. 참조된 에셋은 임포트 중에 확인됩니다.
resource()
함수는 Resources
폴더 또는 Editor Default Resources
폴더에 있는 파일을 허용합니다. 단, 다음 사항에 유의하십시오.
Resources
폴더에 있는 경우 파일 확장자를 포함하지 마십시오. 예: background-image: resource("Images/my-image")
Editor Default Resources
폴더에 있는 경우 파일 확장자를 포함해야 합니다. 예: background-image: resource("Images/default-image.png")
url()
함수는 파일 경로가 프로젝트 루트 또는 USS 파일이 들어 있는 폴더 중 하나와 관련되었다고 예상합니다. 파일 확장자는 반드시 포함해야 합니다. 예: background-image: url("Images/my-image.png")
텍스처의 경우 파일에 @2x
접미사가 있는 버전이 있으면 이 파일은 레티나 또는 고DPI 스크린에 대해 자동으로 로드됩니다.
큰따옴표를 사용하여 문자열 값을 지정하십시오. 예: my-property: "foo"
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.