Unity 4.6 Change the content from a text Object through script

Hi,
I have got the problem that I want to change a text GUI element through script in unity 4.6 for showing a score in my game but I do not get it to work because I dont know how to access the Text component. So if anyone could help me I would be rally happy :slight_smile:

P.S.: Iā€™m sorry for my bad english

You get it like anything else.

// UnityScript
import UnityEngine.UI;

var someText: Text;

function Start()
{
  someText = GetComponent.<Text>(); //
}

function Update()
{
  someText.text = "Hello and junk";
}

// c#
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SomeScriptName : MonoBehaviour
{
  public Text someText;

  void Start()
  {
    someText = GetComponent<Text>();
  }

  void Update()
  {
    someText.text = "Hello im some text";
  }
}

I wrote the following function, based on @Ace_Flooders excellent answer, for finding text elements by name using Linq:

private Text GetTextObjectByName(string name)
{
	var canvas = GameObject.Find("Canvas");
	var texts = canvas.GetComponentsInChildren<Text>();
	return texts.FirstOrDefault(textObject => textObject.name == name);
}