Hi everyone,
I’m a beginner in programming and I’m trying to change the color of my material by using a UI with 3 sliders.
I manage to change the color with the slider but it’s only affect the script and not the material (I create a visualization of the color in the script, that I can see in the inspector of my mesh).
I’m very closed, I just need to match my color with the one of material and it will be good and I can’t found how to do it.
Here the code:
public Color altColor;
public Renderer rend;
public Material colors;
void slider()
{
altColor.r = 0.5f;
altColor.g = 0.5f;
altColor.b = 1.0f;
}
void Start ()
{
slider();
Renderer rend = GetComponent<Renderer>();
rend.material.color = altColor;
//Material rend = GetComponent<Material>();
//rend.material.colorRed = altColor;
}
public void colorRed (float newRed)
{
altColor.r = newRed;
}
public void colorGreen(float newGreen)
{
altColor.g = newGreen;
}
public void colorBlue(float newBlue)
{
altColor.b = newBlue;
}
// Update is called once per frame
void Update () {
}