Hi
I am trying to change the color of my gameobject called p911 to specific colors by pushing buttons that I defined them in script, but I get the error that cannot convert string to bool. if anyone that can help I would appreciate it.
if there are any problems in my other parts of code, please tell me.
thank you.
public class ChangeColor : MonoBehaviour {
private GameObject P911 = new GameObject();
private GameObject turnred = new GameObject();
private GameObject turnblack = new GameObject ();
private GameObject turnwhite = new GameObject ();
private GameObject turnyellow = new GameObject ();
// Use this for initialization
void Start () {
GameObject.Find ("P911").renderer.enabled = true;
GameObject.Find ("turn-red").renderer.enabled = true;
GameObject.Find ("turn-black").renderer.enabled = true;
GameObject.Find ("turn-white").renderer.enabled = true;
GameObject.Find ("turn-yellow").renderer.enabled = true;
P911 = GameObject.Find ("P911");
turnred = GameObject.Find ("turn-red");
turnblack = GameObject.Find ("turn-black");
turnwhite = GameObject.Find ("turn-whit");
turnyellow = GameObject.Find ("turn-yellow");
}
void OnMouseDown ()
{
//P911.gameObject.renderer.material.color = new Color (r, g, b, a);
gameObject.renderer.material.color = new Color (11,22,33,123);
if ("turn-red") {
P911.renderer.material.color = new Color (232, 0, 0, 255);
} else if ("turn-black") {
P911.renderer.material.color = new Color (0, 0, 0, 255);
} else if ("turn-white") {
P911.renderer.material.color = new Color (184, 184, 184, 255);
} else if ("turn-yellow") {
P911.renderer.material.color = new Color (201, 187, 0, 255);
}
}
}