USS를 사용하여 전체 텍스트 문자열을 스타일링할 수 있습니다. 하지만 텍스트 문자열의 한 단어만 스타일링하려면 어떻게 해야 하나요?이것은 USS의 경우에는 어렵지만 리치 텍스트 태그의 경우에는 간단합니다.
리치 텍스트 태그는 텍스트 문자열 안에 배치하여 태그 사이의 텍스트를 스타일링할 수 있는 태그입니다.
지원되는 모든 태그는 지원되는 태그를 참조하십시오.
참고:현재 릴리스에서 리치 텍스트 태그는 TextField에 대해 지원되지 않습니다.
리치 텍스트 태그는 HTML 또는 XML 태그와 유사하지만 구문이 덜 엄격합니다.
단순 태그는 이름만 있고 추가 값이나 속성이 없을 수 있습니다.예를 들어, <b>
태그는 텍스트를 굵게 만듭니다.
일부 태그에는 다음과 같은 추가 값 또는 속성이 있습니다.
<tag="value">
<tag attribute="value">
예제:
<color="red">
:텍스트를 빨간색으로 설정<sprite index=3>
:기본 스프라이트 에셋으로부터 네 번째 스프라이트를 삽입합니다.참고:UXML 파일에서 다음 문자에 대해 HTML 코드를 사용해야 합니다.
<
:(<)
>
:(>)
"
:(")
다음 표에는 사용 가능한 속성 값 타입과 예시 값이 나와 있습니다.
값 타입 | 예시 값 |
---|---|
소수점 | 0.5 |
백분율 | 25% |
픽셀 값 | 5px |
폰트 단위 | 1.5em |
16진수 컬러 값 |
#FFFFFF (RGB)#FFFFFFFF (RGBA)#FF (A) |
이름 |
<link="ID"> 및 <link=ID> 이(가) 모두 유효합니다. |
태그에는 텍스트에 영향을 주는 정도를 정의하는 범위가 있습니다.대부분의 경우 텍스트의 특정 지점에 추가된 태그는 해당 지점 이후의 모든 텍스트에 영향을 미칩니다.
예를 들어 텍스트 시작 부분에 <color="red">
태그를 추가하면 전체 텍스트 블록에 영향을 줍니다.<color="red">This text is red
.
텍스트 블록 중간에 동일한 태그를 추가하면 태그와 블록 끝 사이의 텍스트에만 영향을 줍니다.This text turns<color="red"> red
.
텍스트 블록에서 동일한 태그를 두 번 이상 사용하는 경우 마지막 태그가 동일한 유형의 이전 태그를 모두 대체합니다.<color="red">This text goes from red<color="green"> to green
.
닫는 태그를 사용하여 태그의 범위를 제한하고 다른 태그 내에 중첩 태그를 사용할 수도 있습니다.<color=red>This text is <color=green>mostly </color>red
첫 번째 <color>
태그의 범위는 전체 텍스트 블록입니다.두 번째 <color>
태그에는 범위를 한 단어로 제한하는 닫는 태그가 있습니다.
태그를 중첩할 때는 태그를 시작한 순서대로 범위를 닫지 않아도 됩니다.
리치 텍스트 태그는 기본적으로 활성화되어 있습니다.
리치 텍스트 태그를 비활성화하려면 다음 중 하나를 수행하십시오.
enable-rich-text
속성을 false
로 설정합니다.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.