Version: 2022.1
言語: 日本語
Sprite Asset properties reference
Panel Text Settings assets

Color gradients

You can apply gradients of up to four colors to text. When you add a color gradient, TextCore applies gradient colors to each character in a text string.

Use the the <gradient> rich text tags to apply color gradient presets to text objects. A gradient preset overrides the text’s local gradient type and colors.

Create a color gradient preset

To create a color gradient with one or more colors, and place it in a specific folder, follow these steps:

  1. From the menu, select Assets > Create > Text > Color Gradient to add a new color gradient preset.

  2. In the Color Gradient’s Inspector window, select a color mode from the dropdown menu:

    • Single: Applies a single color.
    • Horizontal Gradient: Applies two colors and produces a side-to-side transition between them on each character.
    • Vertical Gradient: Applies two colors and produces an up-and-down transition between the two on each character.
    • Four Corners Gradient: Applies four colors. Each color radiates from its assigned corner of each character.
  3. Set the gradient colors. The number of colors available in the Colors field depends on the gradient mode you choose. Each swatch corresponds to the color’s origin on a character sprite.

  4. Place the color gradient asset into the path set for the Color Gradient Presets in the Panel Text Setting asset.

Apply color gradient presets

To apply a color gradient preset to text, reference the color gradient by name as <gradient="name-of-the-color-gradient">Your text</gradient>. If you apply the color gradient like this, the color of the text is multiplied by the object’s current vertex colors.

To apply the pure gradient to a selection of text, use a <color> tag to reset the color to white. For example:

<color=white><gradient="Light to Dark Green - Vertical">Light to Dark Green gradient</gradient></color>

Color gradient mode examples

The following shows color gradient examples for each mode.

Single color

A single-color gradient.

Text with each character in yellow.
Text with each character in yellow.

Horizontal gradients

A side-to-side gradient with two colors.

Text with color transition from yellow to black side-to-side for each character.
Text with color transition from yellow to black side-to-side for each character.
Text with color transition from black to yellow side-to-side for each character.
Text with color transition from black to yellow side-to-side for each character.

Vertical gradients

An up-and-down gradient with two colors.

Text with color transition from black to yellow up-and-down for each character.
Text with color transition from black to yellow up-and-down for each character.
Text with color transition from yellow to black up-and-down for each character.
Text with color transition from yellow to black up-and-down for each character.

Four corner gradients

A gradient with four colors. Each color radiates from one corner. This is the most versatile gradient type. You can vary some colors and keep others identical to create different kinds of gradients.

Text with four-color gradient for each character with yellow on the up-left, black on the up-right, red on the down-left, and green on the down-right.
Text with four-color gradient for each character with yellow on the up-left, black on the up-right, red on the down-left, and green on the down-right.

This example shows three corners with one color and the fourth with a different color.

Text with four-color gradient for each character with black on the up-left and yellow for the other corners.
Text with four-color gradient for each character with black on the up-left and yellow for the other corners.

This example shows pairs of adjacent corners with the same color to create horizontal or vertical gradients.

Text with four-color gradient for each character with black on the left up and down, and yellow on the right up and down.
Text with four-color gradient for each character with black on the left up and down, and yellow on the right up and down.
Text with four-color gradient for each character with black on the up left and right, and yellow on the down left and right.
Text with four-color gradient for each character with black on the up left and right, and yellow on the down left and right.

This example shows pairs of diagonally opposite corners the same color to create diagonal gradients.

Text with four-color gradient for each character with black on the up-left and down-right, and yellow on the up-right and down-left.
Text with four-color gradient for each character with black on the up-left and down-right, and yellow on the up-right and down-left.
Text with four-color gradient for each character with yellow on the up-left and down-right, and black on the up-right and down-left.
Text with four-color gradient for each character with yellow on the up-left and down-right, and black on the up-right and down-left.

This example creates horizontal and vertical three-color gradients with a dominant color at one end and a transition between two colors at the other.

Text with four-color gradient for each character with yellow on the left up and down, red on the up-right, and black on the down-right.
Text with four-color gradient for each character with yellow on the left up and down, red on the up-right, and black on the down-right.
Text with four-color gradient for each character with yellow on the up left and right, red on the down-left, and black on the down-right.
Text with four-color gradient for each character with yellow on the up left and right, red on the down-left, and black on the down-right.

This example gives two diagonally opposite corners the same color and the other two corners different colors to create a diagonal stripe three-color gradient.

Text with four-color gradient for each character with red on the up-left, yellow on the up-right and down-left, and black on the down-right.
Text with four-color gradient for each character with red on the up-left, yellow on the up-right and down-left, and black on the down-right.
Text with four-color gradient for each character with yellow on the up-left and down-right, black on the up-right, and red on the down-left.
Text with four-color gradient for each character with yellow on the up-left and down-right, black on the up-right, and red on the down-left.

その他の参考資料

Sprite Asset properties reference
Panel Text Settings assets
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961