Public 2D array, accessed through the editor ??

I am trying to declare a public multidimensional array of GameObjects(Using JavaScript not c#) that I can access through the editor. However it would appear that only single dimension arrays are usable through the property inspector.

can anyone please help me out with this i know it is easily possible with c# but i want to know how it can be achieved using javascript.

Thanks in Advance

What I have done is declare a custom class that has an array as a variable. Declare a new array of this class and you have your multi-dimensional array that can be viewed in the editor without any fuzz.
Here’s an example in UnityScript, but it should be easily convertible to C#.

class Array2D {
	var subArray : GameObject[] = new GameObject [12];

var my2DArray: Array2D [] = new Array2D [12];

function PrintArrayContent() {
     if(my2DArray[0].subArray[0] != null) {

You could also write your own Custom Editor/Inspector code or use this code as a

In know its in c# but just use [this][1] its not that hard to convert and just look at the docs for a custom editor.

using UnityEngine;
using System.Collections;
using UnityEditor;

public class BackgroundEditor : Editor {

	bool isShowing;
	bool[] b;

	bool a;

	void Start()
		BackgroundMaster myBGMaster = (BackgroundMaster)target;
		b = new bool[2/*myBGMaster.backgroundItems.GetLength(0)*/];

	public override void OnInspectorGUI()
		BackgroundMaster myBGMaster = (BackgroundMaster)target;

		isShowing = EditorGUILayout.Foldout(isShowing, "Background Items");
			//Debug.Log(b.Length + (b[0]?"T":"F") + (b[1]?"T":"F"));
			if(b != null && b.Length > 0)
				for(int i = 0; i < b.Length; i++)
					string s = "";
					if(i == 0)
						s = "    Foreground";
					else if(i == 1)
						s = "    Midground";
						s = "    Background";

					b _= EditorGUILayout.Foldout(b*, s);*_

_ if(b*)
for(int j = 0; j < myBGMaster.backgroundItems.GetLength(1); j++)
if(myBGMaster.backgroundItems[i, j])
EditorGUILayout.LabelField(" “, myBGMaster.backgroundItems[i, j].name);
* EditorGUILayout.LabelField(” N/A");
* {
EditorGUILayout.LabelField(" N/A");
EditorGUILayout.LabelField((" [" + myBGMaster.backgroundItems.GetLength(0)) + ", " + myBGMaster.backgroundItems.GetLength(1) + “]”);
Or you could have a look at this [Unity tutorial][2]
Hope this helps later viewers,



I stumbled in this same issue a month ago and after solving it, I have made a solution to this, now. I have made a grid view for a 2D array.

You can find it here: Unity3D - 2D Array In Inspector - YouTube

Its in c# though.