Editing a jagged array?

Hello. I am trying to edit a jagged array that I have in my script, but it is not showing up in the project inspector…why? Thanks

 var Test : int[,];

Well, for starters that’s not a jagged array, it’s a multidimensional array. The important difference is that in a jagged array, each of the ‘rows’ is a different length, whereas in a multidim array they are always rectangular.

Anyway, Unity’s default inspector can’t edit multidim arrays. It’s annoying, I know, but that’s how it is. Unity can’t serialize them, so there’s no point having an editor for them. My usual workaround is to create a custom class which provides all the same functionality, but which is implemented in a way that Unity can serialize it. Unfortunately, I always work in C#, so I’m not sure how useful any of my code would be to you (I rely quite a lot on operator overloading, so that I can use the ‘myArray[x,y]’ notation to access elements, which I have absolutely no clue how to do in JS).

You can always write a custom class, and a special editor for them. It’s tricky and longwinded, but worthwhile if you can use them in a lot of places. I’m sure if you look around, you’ll find a few packages like this that people have put up on the internet.

Did you try “[System.Serializable]”?

public class YourClass: MonoBehaviour {