Gradient

class in UnityEngine

매뉴얼로 전환

설명

Gradient used for animating colors.

using UnityEngine;

public class ExampleScript : MonoBehaviour { Gradient gradient; GradientColorKey[] colorKey; GradientAlphaKey[] alphaKey;

void Start() { gradient = new Gradient();

// Populate the color keys at the relative time 0 and 1 (0 and 100%) colorKey = new GradientColorKey[2]; colorKey[0].color = Color.red; colorKey[0].time = 0.0f; colorKey[1].color = Color.blue; colorKey[1].time = 1.0f;

// Populate the alpha keys at relative time 0 and 1 (0 and 100%) alphaKey = new GradientAlphaKey[2]; alphaKey[0].alpha = 1.0f; alphaKey[0].time = 0.0f; alphaKey[1].alpha = 0.0f; alphaKey[1].time = 1.0f;

gradient.SetKeys(colorKey, alphaKey);

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

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.

변수

alphaKeysAll alpha keys defined in the gradient.
colorKeysAll color keys defined in the gradient.
modeControl how the gradient is evaluated.

생성자

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