using UnityEngine;
using System.Collections;
public class Paint : MonoBehaviour {
public Material[] PaintColor;
public MeshRenderer ChangeColor;
public Renderer rend;
void Start ()
{
}
public void Change ()
{
ChangeColor.materials [1] = PaintColor [0];
}
}
xxZap
2
(In C# variable names start with lowercase letter)
for change the material color use:
gameObject.renderer.material.color = Color.black;
“black” in this case is like other default colors like .red .white ecc… see here: Color Docs
If you want to be more accurate you can create your RGB color with:
new Color(R, G, B).
where R, G, B are floats from 0.0 to 1.0.
using UnityEngine;
using System.Collections;
public class Paint : MonoBehaviour {
private MeshRenderer renderer;
void Awake()
{
renderer = GetComponent<MeshRenderer>();
}
public void ChangeTint(Color color)
{
renderer.material.color = color;
}
}