Listを二重に使った際のメモ
初期化はこちら
//配列[1]の中の配列を初期化 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>>()//リストの宣言 { // Listの中にListを追加して初期化 new List<int>(),//[0]の中の配列 new List<int>(),//[1]の中の配列 new List<int>(),//[2]の中の配列 }; 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]); //配列[1]の中の配列を初期化 Debug.Log("配列[1]の中の配列を初期化"); Test_List[1] = new List<int>(); //配列0の中の配列の中を全部見る 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]); } } }