LoginSignup
1
2

More than 5 years have passed since last update.

Unity ~他のオブジェクトからメソッド呼び出し~

Last updated at Posted at 2017-01-08

コード

CountDownTXTオブジェクトのCountDownスクリプトのCountメソッドを使いたい時


GameObject CountDownTxt;

void Start () {
        CountDownTxt = GameObject.Find("CountDownTXT");
}

void Update () {
        CountDownTxt.GetComponent<CountDown>().Count();
}

他にも使いまわしたいなら

CountDown cd = CountDownTxt.GetComponent<CountDown>();
cd.Count();

こんなんとかね

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2