- Home /
How to expose member variables to the inspector in C#?
It seems to me that a member variable of a self-defined class is not showing up in the inspector. what's the right way to do it?
also, In Javascript I know one could change the size of an Array in the inspector, can I do the same thing with C#?
The following is my script:
public class MetaMorph : MonoBehaviour {
public MetaMorph_Setting_class MetaMorph_Settings = new MetaMorph_Setting_class();
public class MetaMorph_Setting_class { public GameObject MM_Mesh_Object; public bool MM_Is_Boned = true; }
public List< Diff_Map_class > Diff_Maps = new List< Diff_Map_class >();
public class Diff_Map_class { public string Name; public Texture2D DM_Image; }
Answer by PatHightree · Oct 10, 2011 at 02:43 PM
Your data classes should have the [Serializable] attribute, like this:
public class MetaMorph : MonoBehaviour {
[Serializable]
public class MetaMorph_Setting_class { public GameObject MM_Mesh_Object; public bool MM_Is_Boned = true; }
public MetaMorph_Setting_class MetaMorph_Settings = new MetaMorph_Setting_class();
[Serializable]
public class Diff_Map_class { public string Name; public Texture2D DM_Image; }
public List<Diff_Map_class> Diff_Maps = new List<Diff_Map_class>();
}