How can I change material color smoothly with C# like in Magnets Game?
Hello everybody. I am trying to make a game using the same background like in MAGNETS GAME.
Please take a look at this video and you will see what exactly i am looking for.
How can we change the color like in this game ?
Answer by Graphics_Dev · Mar 02, 2016 at 08:15 PM
Here is a simple script to rotate through hues ;)
using UnityEngine;
using System.Collections;
public class HueRotater : MonoBehaviour {
public float hue = 0f;
public float sat = 1f;
public float val = 1f;
public float speed = 0.0005f;
private Renderer rend;
// Use this for initialization
void Start () {
rend = GetComponent<Renderer>();
}
// Update is called once per frame
void Update () {
if (hue < 1) {
hue = hue + speed;
} else {
hue = 0;
}
rend.material.color = Color.HSVToRGB (hue, sat, val);
}
}
I have a zip here if you would like to see the demo I just made =)
Let me know if this helps ;)
Assets/HueRotate/HueRotater.cs(24,45): error CS0117: UnityEngine.Color' does not contain a definition for
HSVToRGB'
That's strange :(
http://docs.unity3d.com/ScriptReference/Color.HSVToRGB.html
I don't have any errors...were you using my zipped demo?
What version of Unity are you using?
The error has:
HSVToRGB'
Do you actually have an apostrophe after HSVToRGB in the code?
Your answer
Follow this Question
Related Questions
Reverse the way image color affects colors 1 Answer
Changing color in in runtime to a cube 0 Answers
Change individual sprite pixel colours through script. 0 Answers
Problem with color Change 2 Answers
How to make RANDOM COLOR on shader 1 Answer