I have a problem with a recently modified class not showing up in the inspector.
I am attempting to make a class which I can use to automatically stitch up generic list of key/value pairs into a dictionary. However, I am unable to get the class to show up in the inspector when it is added to a behavior. This was working, until I modified the class to act more like a data container by modifying the logic to allow for the getData and setData methods.
I am including the new non-functioning code, as well as an example behavior that I was using to test.
[System.Serializable]
public class MapList<Key, Data>
{
//Should never be accessed directly in code
//but needs to be public for serialization
public List<Link> maps;
public Link nullLink;
private Dictionary<Key, Link> m_dict;
protected Dictionary<Key, Link> stitchedDict{
get{
if (
this.maps == null
|| this.m_dict == null
|| this.maps.Count != this.m_dict.Count
) {
restitchDict ();
}
return this.m_dict;
}
set{ this.m_dict = value; }
}
public Data getData (Key key)
{
if (this.stitchedDict.ContainsKey (key)) {
return this.stitchedDict[key].data;
} else {
return this.nullLink.data;
}
}
public void setData (Key _key, Data _data)
{
if (this.stitchedDict[_key] == null) {
Link dataMap = new Link ();
dataMap.key = _key;
dataMap.data = _data;
this.addMap (dataMap);
this.restitchDict ();
} else {
this.stitchedDict[_key].data = _data;
}
}
protected void restitchDict ()
{
if(this.m_dict == null){
this.m_dict = new Dictionary<Key, Link> ();
}
this.m_dict.Clear ();
this.validateMaps ();
foreach (Link nextMap in this.maps) {
this.m_dict[nextMap.key] = nextMap;
}
}
protected void addMap (Link _dataMap)
{
this.validateMaps ();
this.maps.Add (_dataMap);
}
protected void validateMaps ()
{
if (this.maps == null) {
this.maps = new List<Link> ();
}
}
//INTERNAL CLASSES
[System.Serializable]
public class Link
{
public Key key;
public Data data;
}
}
public class ExecBehavior : MonoBehaviour {
public MapList<string, int> exampleMap;
public List<string> compare1;
public List<int> compare2;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}