facebook twitter hatena line email

「Unity/GameObject」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「==子供のオブジェクト取得== GameObject child = obj.transform.Find("Child1Image").gameObject; ==非アクティブへ== obj.SetActive(true);」)
 
(ボタンなどが貼り付けられてるクラスからGameObject取得)
(同じ利用者による、間の4版が非表示)
行4: 行4:
 
==非アクティブへ==
 
==非アクティブへ==
 
  obj.SetActive(true);
 
  obj.SetActive(true);
 +
 +
==オブジェクトより手前に==
 +
Transform trans1 = GameObject.Find("Object1").transform;
 +
trans1.SetSiblingIndex(0);
 +
 +
==ボタンなどが貼り付けられてるクラスからGameObject取得==
 +
<pre>
 +
GameObject btnObj = GameObject.Find("Button");
 +
Button btn = btnObj.GetComponent<Button>();
 +
GameObject obj = btn.gameObject;
 +
</pre>
 +
 +
==こちらも参照==
 +
[[Unity/Csharp/オブジェクト操作]] [ショートカット]

2021年10月14日 (木) 17:58時点における版

子供のオブジェクト取得

GameObject child = obj.transform.Find("Child1Image").gameObject;

非アクティブへ

obj.SetActive(true);

オブジェクトより手前に

Transform trans1 = GameObject.Find("Object1").transform;
trans1.SetSiblingIndex(0);

ボタンなどが貼り付けられてるクラスからGameObject取得

GameObject btnObj = GameObject.Find("Button");
Button btn = btnObj.GetComponent<Button>();
GameObject obj = btn.gameObject;

こちらも参照

Unity/Csharp/オブジェクト操作 [ショートカット]