17/08/23 12:29:22.72 0fyfcMVA.net
>>768
using UnityEngine;
using System.Collections;
public class Nichan_767 : MonoBehaviour {
private GameObject[] buttons = new GameObject[25];
// Use this for initialization
void Start() {
Debug.Log("Length=" + buttons.Length); // ①24と表示される
buttons = GameObject.FindGameObjectsWithTag("button");
Debug.Log("Length=" + buttons.Length); // ②0と表示される
}
}
①の時点では
private GameObject[] buttons = new GameObject[25];
で確保した物は存在していますが
②の結果から
buttons = GameObject.FindGameObjectsWithTag("button");
ここで配列を再構築してるのを理解いただけるかと思います。
仮にTag"button"のGameObjectを3つ配置すると②の結果は3に変化します。
このように1行1行の命令が何をしているのか、そして動きの変化を丁寧に見ている事が大切になりますよ。
参考にしてみてください。