# Shared Material

I have this simple script, so the user touch one of the cubes all cubes with same material will change color.

One of this cubes must have the name of the color on it, only one, so the user touch the cube written RED and all cubes related to material RED will change color to RED.

I can't figure out how to write the name of the color in this unique cube. :( need help....

using UnityEngine;
using System.Collections;

public class allCubes : MonoBehaviour {

public Color defaultColor;
public Color selectedColor;
private Material mat;

void Start(){
mat = renderer.sharedMaterial;
mat.color = defaultColor;
}

void OnTouchDown () {
mat.color = selectedColor;
}

void OnTouchUp () {
mat.color = defaultColor;
}

void OnTouchStay () {
mat.color = selectedColor;
}

void OnTouchExit () {
mat.color = defaultColor;
}
}