using UnityEngine;
public class ColorChanger : MonoBehaviour
{
public Color color1;
public Color color2;
private Renderer renderer;
private void Start()
{
this.renderer = this.GetComponent<Renderer>();
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Hand"))
{
Material material = this.renderer.material;
float b = this.color1.b;
float a = this.color1.a;
float r = this.color1.r;
float g = this.color1.g;
material.color = new Color(r, g, b, a);
return;
}
}
private void OnTriggerExit(Collider other)
{
if (other.CompareTag("Hand"))
{
Material material = this.renderer.material;
float b = this.color2.b;
float a = this.color2.a;
float r = this.color2.r;
float g = this.color2.g;
material.color = new Color(r, g, b, a);
return;
}
}
public ColorChanger()
{
base();
}
}