Public array in the inspector

Hi, I’m following about this, but I don’t understand or I don’t do well for doing this.
I will make a public array, for example, of materials, but when I put:

public class humanCreation : MonoBehaviour {

Material[] skinPrefabs;   // for exeple

 Material[] skinPrefabs = new Material[6];  // or this for exemple

}

Don’t appear nothing in the inspector, so I make this:

public class humanCreation : MonoBehaviour {

    public Material body1;       //cuerpo
    public Material body2;
    public Material body3;
    public Material body4;
    public Material body5;
    public Material body6;

void creationSkin()
    {
        Material[] skinPrefabs = new Material[6];
        skinPrefabs[0] = body1;
        skinPrefabs[1] = body2;
        skinPrefabs[2] = body3;
        skinPrefabs[3] = body4;
        skinPrefabs[4] = body5;
        skinPrefabs[5] = body6;
        body.GetComponent<Renderer>().material = skinPrefabs[Random.Range(0, skinPrefabs.Length - 1)];

}

I know that I can optimize which switch but I prefer doing the public array in the inspector… If always tell me how I can do a public array I will stay very happy xD

pd: sorry for my English :frowning:

In order to edit public variables in the Inspector, you need to use the “public” modifier.

public Material

Hi, you just forgot the “public” qualifier on the array: “public Material skinPrefabs” will make it appear in the inspector and serialized.