Skip to content

Instantly share code, notes, and snippets.

@nrfm
Created September 30, 2017 07:44
Show Gist options
  • Save nrfm/95ddbf5c5b38be6621b262b7dff3dd76 to your computer and use it in GitHub Desktop.
Save nrfm/95ddbf5c5b38be6621b262b7dff3dd76 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class MaterialColorChanger : MonoBehaviour
{
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;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment