Version: 2022.2
언어: 한국어

Gradient

class in UnityEngine

매뉴얼로 전환

설명

Represents a Gradient used for animating colors.

Gradients allow animating or interpolating colors by having several "color keys" and "alpha keys". Color keys and alpha keys are separate, and each key has a time specified for it, ranging from 0.0 (0%) to 1.0 (100%). Note that the alpha and colors keys will be automatically sorted by time value and that it is ensured to always have a minimum of 2 color keys and 2 alpha keys.

How the colors are interpolated between the keys is controlled by GradientMode.

Public Gradient variables used in scripts automatically display the gradient editor in the inspector window. GradientUsageAttribute allows specifying whether the gradient colors should be high dynamic range for editing.

using UnityEngine;

public class ExampleScript : MonoBehaviour { void Start() { var gradient = new Gradient();

// Blend color from red at 0% to blue at 100% var colors = new GradientColorKey[2]; colors[0] = new GradientColorKey(Color.red, 0.0f); colors[1] = new GradientColorKey(Color.blue, 1.0f);

// Blend alpha from opaque at 0% to transparent at 100% var alphas = new GradientAlphaKey[2]; alphas[0] = new GradientAlphaKey(1.0f, 0.0f); alphas[1] = new GradientAlphaKey(0.0f, 1.0f);

gradient.SetKeys(colors, alphas);

// What's the color at the relative time 0.25 (25%) ? Debug.Log(gradient.Evaluate(0.25f)); } }

변수

alphaKeysAll alpha keys defined in the gradient.
colorKeysAll color keys defined in the gradient.
colorSpaceIndicates the color space that the gradient color keys are using.
modeControls how the gradient colors are interpolated.

생성자

GradientCreate a new Gradient object.

Public 함수

EvaluateCalculate color at a given time.
SetKeysSetup Gradient with an array of color keys and alpha keys.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961