# Changing an objects on through C# script in Unity

I am trying to export my Unity project to Android Studio so that I can create some Android buttons that "controls" the Unity app's behavior. I know what I have to do in order to let it access through Java, but I don't know how to change the color. I watched a video about on Youtube, and the guy used: gameObject.renderer.material.color. However, when I try to do the same it can't find material.

This is my script so far:

using UnityEngine;
using System.Collections;

public class ChangeColor : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

{
if (string.Equals(message, "G"))
{
this.gameObject.renderer.m ///It can't find material
}
else if (string.Equals(message, "P"))
{

}
else if (string.Equals(message, "B"))
{

}
}
}

• @JohnHamilton, we do not accept duplicates across sites. Your links are for Stack Overflow, not GameDev. – Gnemlock Dec 13 '16 at 21:37
• @Gnemlock still it shows lack of research. Just looking at the docs (not even requires any thinking) is enough to solve this. – John Hamilton Dec 14 '16 at 5:39

gameObject.GetComponent<MeshRenderer>().material.color

• so like this? gameObject.GetComponent<MeshRenderer>().material.color(Color.black); – user4118143 Dec 13 '16 at 13:12