親を決める
transform.parent = parent; transform.SetParent( parent );
例えば、新しく生成するオブジェクトをひとつの親オブジェクトにまとめる。
ヒエラルキーの見た目がいっぱいにならない。
public GameObject cube2; private void Update(){ if(Input.GetKey(KeyCode.S)){ // ゲームオブジェクトに代入するとき、はas GameObjectが昼用 GameObject o1 = Instantiate(cube2,new Vector3(Random.Range(-3.5f, 3.5f), Random.Range(-3.5f, 3.5f), Random.Range(-3.5f, 3.5f)), Quaternion.identity) as GameObject; // 子要素として入れる。 o1.transform.parent = GameObject.Find("Cubes2").transform; } }