2014年5月30日金曜日

オブジェクトのコンポーネント(Script)を取得 [Unity C#]

スクリプト名「SampleClass」
SampleClassの変数宣言
public string str = "";

//親オブジェクトを取得
GameObject objParent = this.transform.parent.gameObject;
//親オブジェクトのコンポーネント(Script)を取得
SampleClass SC = objParent.GetComponent<SampleClass>();
SC.str = "AAA";



0 件のコメント:

コメントを投稿