Listを二重に使った際のメモ
初期化はこちら
Test_List[1] = new List<int>();
テストで作ったスクリプト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestScript : MonoBehaviour
{
public List<List<int>> Test_List = new List<List<int>>()
{
new List<int>(),
new List<int>(),
new List<int>(),
};
void Start()
{
Debug.Log("配列[0]の中の配列[0~2]に5,6,7をいれる");
for (int i = 0; i < 3; i++)
{
Test_List[0].Add(i+5);
Debug.Log(Test_List[0][i]);
}
Debug.Log("配列[1]の中の配列[0~5]に8,9,10,11,12,13をいれる");
for (int n = 0; n < 6; n++)
{
Test_List[1].Add(n+8);
Debug.Log(Test_List[1][n]);
}
Debug.Log("配列[2]の中の配列[0~8]に10,11,12,13,14,15,16,17,18をいれる");
for (int p = 0; p < 9; p++)
{
Test_List[2].Add(p+10);
Debug.Log(Test_List[2][p]);
}
Debug.Log("配列[0]の中の配列[1]は" + Test_List[0][1]);
Debug.Log("配列[1]の中の配列[1]は" + Test_List[1][1]);
Debug.Log("配列[2]の中の配列[1]は" + Test_List[2][1]);
Debug.Log("配列[1]の中の配列を初期化");
Test_List[1] = new List<int>();
Debug.Log("配列[0]の中身");
for (int i1 = 0; i1 < Test_List[0].Count; i1++)
{
Debug.Log(Test_List[0][i1]);
}
Debug.Log("配列[1]の中身");
for (int n1 = 0; n1 < Test_List[1].Count; n1++)
{
Debug.Log(Test_List[1][n1]);
}
Debug.Log("配列[2]の中身");
for (int p1 = 0; p1 < Test_List[2].Count; p1++)
{
Debug.Log(Test_List[2][p1]);
}
}
}
参考
ict119.com
smdn.jp