用户工具

站点工具


侧边栏

script:unityengine:classes:gradient:gradient

Gradient 渐变

class in UnityEngine

Description 描述

Gradient used for animating colors.

用于动画颜色渐变。

JavaScript:

function Start () {
    var g : Gradient;
    var gck : GradientColorKey[];
    var gak : GradientAlphaKey[];
 
    g = new Gradient();
 
    // Populate the color keys at the relative time 0 and 1 (0 and 100%)
    gck = new GradientColorKey[2];
    gck[0].color = Color.red;
    gck[0].time = 0.0f;
    gck[1].color = Color.blue;
    gck[1].time = 1.0f;
 
    // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
    gak = new GradientAlphaKey[2];
    gak[0].alpha = 1.0f;
    gak[0].time = 0.0f;
    gak[1].alpha = 0.0f;
    gak[1].time = 1.0f;
 
    g.SetKeys(gck, gak);
 
    // What's the color at the relative time 0.25 (25 %) ?
    Debug.Log(g.Evaluate(0.25f));
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void Start() {
        Gradient g;
        GradientColorKey[] gck;
        GradientAlphaKey[] gak;
        g = new Gradient();
        gck = new GradientColorKey[2];
        gck[0].color = Color.red;
        gck[0].time = 0.0F;
        gck[1].color = Color.blue;
        gck[1].time = 1.0F;
        gak = new GradientAlphaKey[2];
        gak[0].alpha = 1.0F;
        gak[0].time = 0.0F;
        gak[1].alpha = 0.0F;
        gak[1].time = 1.0F;
        g.SetKeys(gck, gak);
        Debug.Log(g.Evaluate(0.25F));
    }
}

Variables 变量

alphaKeysAll alpha keys defined in the gradient.
在渐变中定义的所有alpha键。
colorKeysAll color keys defined in the gradient.
在渐变中定义所有的颜色键。

Constructors 构造

GradientCreate a new Gradient object.
创建一个新的渐变对象。

Public Functions 公共函数

EvaluateCalculate color at a given time.
在给定的时间内计算颜色。
SetKeysSetup Gradient with an array of color keys and alpha keys.
设置渐变颜色键和alpha键的数组。
script/unityengine/classes/gradient/gradient.txt · 最后更改: 2016/08/02 05:29 (外部编辑)