- Home /
Question by
davejones1 · Mar 21, 2018 at 04:57 PM ·
c#unity 5
Change colour from random to constant?
using UnityEngine;
using System.Collections;
public class HighlighterSpectrum : HighlighterInteractive
{
public bool random = true;
public float velocity = 0.13f;
private float t;
#region MonoBehaviour
//
protected override void Awake()
{
base.Awake();
t = random ? Random.value : 0f;
}
//
protected override void Update()
{
base.Update();
h.ConstantOnImmediate(ColorTool.GetColor(t));
t += Time.deltaTime * velocity;
t %= 1f;
}
#endregion
}
Comment
Best Answer
Answer by Baktillus · Mar 22, 2018 at 05:02 PM
What are you doing and what do you want to achieve?
if you want to change the behaviour of ColorTool when random == false then you need to check
if(!random)
{
//Pick specific colour
}
in Update(). It maybe it would make more sense to just do that once though, so you could specify the colour elsewhere and set random to false and change your Update to:
protected override void Update()
{
base.Update();
if(random){
h.ConstantOnImmediate(ColorTool.GetColor(t));
t += Time.deltaTime * velocity;
t %= 1f;
}
}
You should edit your original question and give us some more info if that is not what you mean.
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
A real head-scratcher 0 Answers
Object from list in scriptableobject in list 0 Answers
How to make buttons have sound when it is highlighted and clicked? 0 Answers