This serializes:
public class GenericMB<T, V> : MonoBehaviour
{
public T t;
public V v;
}
public class ThisSerializes : GenericMB<int, string>
{
}
i.e. if I have a GO with ThisSerializes
attached to it, ‘t’ and ‘v’ will show up in the inspector.
This works well too:
public class KvpMB : MonoBehaviour
{
public KVP kvp = new KVP();
[Serializable]
public class KVP : GenericKeyValue<int, string>
{
}
}
public class GenericKeyValue< TKey, TValue >
{
public TKey key;
public TValue value;
}
public class ThisSerializesToo : KvpMB
{
}
Howover; not the case here:
public class GenericMB<T, V> : MonoBehaviour
{
public KVP kvp = new KVP();
[Serializable]
public class KVP : GenericKeyValue<T, V>
{
}
}
public class GenericKeyValue< TKey, TValue >
{
public TKey key;
public TValue value;
}
public class ThisDoesNotSerialize : GenericMB<int, string>
{
}
Attaching ThisDoesNotSerialize
to a GO ‘kvp’ doesn’t serialize thus not visible in the inspector.
I don’t get why; I’m not attaching a generic MonoBehaviour; It’s just that I’m inheriting from one. It serialized in the first case, why doesn’t it serialize in this one as well?
Any ideas?
Thanks.