Effect(二十一)—— SM_TransRimShaderIrisator

来源:互联网 发布:淘宝网天猫商城男装 编辑:程序博客网 时间:2024/06/01 12:19

目录为:Assets/Media/Effect/Script/目录下
SM_TransRimShaderIrisator.cs

using UnityEngine;using System.Collections;public class SM_TransRimShaderIrisator: MonoBehaviour{    public float topStr = 2.0f;    public float botStr = 1.0f;    public float minSpeed = 1.0f;    public float maxSpeed = 1.0f;    private float speed = 0.0f;    private float timeGoes;    private bool timeGoesUp = true;    //随机速度    void RandomizeSpeed()    {        speed = Random.Range (minSpeed, maxSpeed);    }    void Start()    {        timeGoes = botStr;        speed = Random.Range (minSpeed, maxSpeed);    }    void Update()    {        if (timeGoes > topStr)        {            timeGoesUp = false;            RandomizeSpeed ();        }        if (timeGoes < botStr)        {            timeGoesUp = true;            RandomizeSpeed ();        }        if (timeGoesUp)        {            timeGoes += Time.deltaTime * speed;        }        if (!timeGoesUp)        {            timeGoes -= Time.deltaTime * speed;        }        var currStr = timeGoes;        renderer.material.SetFloat ("_AllPower", currStr);    }}
原创粉丝点击