Search Unity

Change from random to constant

Discussion in 'Shaders' started by davejones1, Mar 20, 2018.

  1. davejones1

    davejones1

    Joined:
    Jan 19, 2018
    Posts:
    183
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. public class HighlighterSpectrum : HighlighterInteractive
    4. {
    5.     public bool random = true;
    6.     public float velocity = 0.13f;
    7.     private float t;
    8.     #region MonoBehaviour
    9.     //
    10.     protected override void Awake()
    11.     {
    12.         base.Awake();
    13.         t = random ? Random.value : 0f;
    14.     }
    15.     //
    16.     protected override void Update()
    17.     {
    18.         base.Update();
    19.         h.ConstantOnImmediate(ColorTool.GetColor(t));
    20.         t += Time.deltaTime * velocity;
    21.         t %= 1f;
    22.     }
    23.     #endregion
    24. }
    25.