x


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; }

more ▼

asked Oct 10 '11 at 01:58 PM

rambramdt gravatar image

rambramdt
1 11 12 13

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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>();
}
more ▼

answered Oct 10 '11 at 02:43 PM

PatHightree gravatar image

PatHightree
379 7 10 20

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4157
x467
x343
x12

asked: Oct 10 '11 at 01:58 PM

Seen: 1179 times

Last Updated: Oct 10 '11 at 02:43 PM