Need help in understanding and writing wrapper classes
hi, I have a dictionary nested inside a list. So every list item holds an instance of the dictionary (along with other values). I am trying to get both the list with the dictionary to show up in the inspector.
In order to get this working, I have been trying to follow a suggestion of writing a wrapper class, but i can't seem to figure out how to write this. If someone could lead me in the right direction that would be great.
Here's what i have. the following are in 3 different class files)
[System.Serializable] public class Dataclass { public List myList; }
[System.Serializable] public class Wrapper { List nList = new List(); }
[System.Serializable] public class test : MonoBehaviour {
public Dataclass dataclass = new Dataclass ();
public List<Wrapper> nList = new List<Wrapper>();
public int myint = 5;
// Use this for initialization
void Start () {
dataclass.myList.Add (myint);
Wrapper mywrap = new Wrapper ();
nList.Add (mywrap);
}
}
thanks in advance.
Please edit your question, remove the code and readd your original code and make sure you mark it as code this time. Your generic parameters got interpreted as HT$$anonymous$$L tags and were stripped away. If you have trouble with the site navigation there's a site navigation guide on the right
Your answer
Follow this Question
Related Questions
Problem with Lists and Remove 0 Answers
Create group people, Select one or more at random. 1 Answer
Custom class list seen as "none" in inspector. 1 Answer
This returns a syntax error? 1 Answer
Sort a List with a public class 0 Answers