see C# 2D Generic List in inspector

Hi everybody,

I’ve got a “containerList” that have 10 Lists with 45 items in it. The items are made from this class (which is serialized) :

using System;
using UnityEngine;
using System.Collections;
[Serializable]

public class SaveTalentClass {

	[SerializeField]
	public int talId;
	public int talCurRank;
	public int talMaxRank;

	public SaveTalentClass(int id, int cRank, int mRank)
	{
		talId = id;
		talCurRank = cRank;
		talMaxRank = mRank;
	}

	public SaveTalentClass()
	{

	}
}

And I initialize my lists through a for loop like this :

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.Linq;
[System.Serializable]

public class PlayerData : MonoBehaviour {
	
	[SerializeField]
	public List<List<SaveTalentClass>> containerList = new List<List<SaveTalentClass>>();

	void Start ()
	{
		for(int i = 0; i < 10; i++)
		{
			containerList.Add (new List<SaveTalentClass>());
				for(int j = 0; j < 45; j++)
				{
					containerList*.Add (new SaveTalentClass(j,0,0));*
  •  		}*
    
  •  }*
    
  • }*
    But I can’t see my “containerList” in the inspector… I found this thread on a similar issue Serialize Nested Lists - Unity Answers but wasn’t able to adapt my script to make it work.
    Can anyone be kind enough with a beginner and explain me how can I do ?

So I had the same problem a little while ago and it took quit the search to find a solution. But I did get a working solution here it is.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GameController : MonoBehaviour 
{
	public List<ListableClass> containerList = new List<ListableClass>();
}

[System.Serializable]
public class ListableClass
{
	public List<SaveTalentClass> innerList = new List<SaveTalentClass>();
}

I did use a array insted of a list in my code so if it still wil not work you could try that but it should work fine the way it is.

[System.Serializable]
public class SimpleList where T: class
{
public List myList;
}

After you import the class in your project , you can simply reuse it whenever you want by List<SimpleList<SaveTalentClass>> or SimpleList<SaveTalentClass>[]