
GetComponent【ゲットコンポーネント】関数を使う。
その他のUnityに関する記事は【Unity】サイト内Tips記事リンクまとめにまとめてある。
オブジェクト.GetComponent<コンポーネント名>()

以下は具体的なサンプル。TextオブジェクトにText【テキスト】コンポーネントと自作のスクリプトを追加してある。自作のスクリプトからTextコンポーネントのtextプロパティを書き換えるサンプルプログラム。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; //UIを使うのでこれを追加
public class kazoeru : MonoBehaviour{
void Start(){
gameObject.GetComponent().text = "おためし";
}
}
注意点
尚、GetComponentは探し出すような処理であるため、Update【アップデート】関数の中など繰り返し頻繁に利用したい場合は負荷軽減のためにスクリプト内で別途宣言した変数に代入して利用するのが一般的である。以下にそのサンプルを示す。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class kazoeru : MonoBehaviour{
Text kerokero; //Text型変数kerokeroの宣言
void Start(){
//↓変数kerokeroにコンポーネント代入
kerokero = gameObject.GetComponent();
}
void Update(){
//keorkeroのtextプロパティに文字列代入
kerokero.text = "おためし";
}
}