How can I change the color color.b color.g color.r color.a with a slider already present??
This is the script that change the color with the keywords:R,G,B,A
using UnityEngine;
using UnityEngine;
using System.Collections;
public class colored : MonoBehaviour {
public Color altColor = Color.black;
public Renderer rend;
void Example() {
altColor.g = 0f;
altColor.r = 0f;
altColor.b = 0f;
altColor.a = 0f;
}
void Start ()
{
Example();
rend = GetComponent<Renderer>();
//Set the initial color (0f,0f,0f,0f)
rend.material.color = altColor;
}
void Update()
{
if (Input.GetKeyDown (KeyCode.G)){
altColor.g += 0.1f;
rend.material.color = altColor;
}
if (Input.GetKeyDown (KeyCode.R)){
altColor.r += 0.1f;
rend.material.color = altColor;
}
if (Input.GetKeyDown (KeyCode.B)){
altColor.b += 0.1f;
rend.material.color = altColor;
}
if (Input.GetKeyDown (KeyCode.A)){
altColor.a += 0.1f;
rend.material.color = altColor;
}
}
}