How to declare array of arrays that should be visible in inspector?

Hi, I want to create an array of array that should be visible in unity inspector. I have tried different methods by some googling and searching various forums. no errors shown but it is not visible in inspector. tried

[SerializeField]
    public Texture[][] texs;

Maybe this helps:
Custom List, a Unity C# Editor Tutorial (catlikecoding.com)
It’s about editor scripting, not your game scripts.

1 Like

Unity does not support multidimensional or (like in your case) jagged arrays when it comes to serialization. However you can create an array / List of a class that contains another array / List of another type. So you can do

[System.Serializable]
public class TextureRow
{
    public Texture[] textures;
}

[SerializeField]
public TextureRow[] texs;

This can be serialized by Unity. Of course to access a certain texture in your “grid” you have to do tex[col].textures[row] instead of tex[col][row]. Of course when filling this array from code you have to create the TextureRow classes yourself as well as the nested arrays. The inspector will initialize them for you when you edit it in the editor.

2 Likes

Thank you very much. it worked. :slight_smile: