- Home /
change toonshader outline colour in script itween
I am trying to create a rainbow effect on my toon shaders outline. The outline colour need to run through the colours smoothly and keep repeating. I tried following these topics:
http://forum.unity3d.com/threads/86732-Cycling-through-the-color-spectrum
and
http://forum.unity3d.com/threads/40376-hue-shift-a-texture but they seem to be more for the textures colours.
I have used iTween to cycle through a materials default colour and thought I could adopt this for what I need but the first argument for iTween.ColorTo is a gameobject and not a material.
if I run this script and change the first thing in iTween.ColorTo() to this.gameObject then it works on the material as a whole but I am just after changing the outline colour.
Any ideas how to achieve this?
// You can then set the colours in the inspector
public Color[] colors = new Color[0];
void Update()
{
if(Input.GetKeyDown("u"))
{
StartCoroutine(ChangeColour());
}
}
IEnumerator ChangeColour()
{
iTween.ColorTo(this.gameObject.renderer.material.SetColor("_OutlineColor",colors[0]),colors[1],5.0f);
yield return new WaitForSeconds(5.0f);
}