// Use this for initialization void Start() { string tg=""; if (gameObject.name.Equals("PlayText")) tg="PlaySelected"; if (gameObject.name.Equals("ScoresText")) tg="ScoresSelected"; if (gameObject.name.Equals("ExitText")) tg="ExitSelected"; if(gameObject.name.Equals("InstructionsText")){ tg="InstructionsSelected"; } GameObject clock = GameObject.Find(tg); this.background = (ShowBackground)clock.GetComponent(typeof(ShowBackground)); this.ts = (TextMesh)gameObject.GetComponent("TextMesh"); this.GetComponent<Renderer>().material.color = background.getColor(); }