I created a new project and added a simple script. It compiles, but doesn't work at runtime. I use C#, Microsoft Visual Studio 2015. I did next: 1. GameObject/3d Object/Cube. 2. Add Component. 3. New Script. 4. C Sharp. 5. Create and Add. 6. I copied the next script from Unity tutorial and pasted: Code (CSharp): using UnityEngine; using System.Collections; public class NewBehaviourScript : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.R)) { GetComponent<Renderer>().material.color = Color.red; } if (Input.GetKeyDown(KeyCode.G)) { GetComponent<Renderer>().material.color = Color.green; } if (Input.GetKeyDown(KeyCode.B)) { GetComponent<Renderer>().material.color = Color.blue; } } } Nothing happens, when I press R, G, B. I checked other scripts and they don't work in the the same way.
I copied your script, putting it into a NewBehaviourScript.cs file, attaching it to a 3D cube in the scene, pressed play and it works perfectly with R, G, B. Check that you didn't rename the .CS file: it has got to be the same as the classname (in this case NewBehaviourScript). Check that you put the script ON the actual cube. It cannot work on any other object than the one with the renderer.