Arrays don't show up on inspector

I have these two classes and both of them don’t show up the arrays on inspector. Does someone can help me out why?

public class TowerSystemManager : MonoBehaviour
{
public LevelTowerSystemController[ ] towerType = new LevelTowerSystemController[ 4 ];
}

[System.Serializable]
public class LevelTowerSystemController : MonoBehaviour
{
public GameObject[ ] towerLevel = new GameObject[ 2 ];

public GameObject this[ int i ]
{
get
{
return towerLevel[ i ];
}
set
{
towerLevel[ i ] = value;
}
}

public int Length
{
get
{
return towerLevel.Length;
}
}
}

If you are looking for them to nest within each other in the inspector, I don’t think the Unity editor supports that. (Someone hop in and correct me if I’m wrong.)

You could make prefabs of each of the types of LevelTowerSystemControllers you want, and then stick those into an array inside of TowerSystemManager. You would just make a blank game object with the LevelTowerSystemController on it, set it up, and save it as a prefab, then drag those four things into TowerSystemManager’s public array.

Perhaps a silly question but did you click the little arrow next to the variable name in the inspector? I can’t duplicate your issue.

It does, you can nest about 16 levels down. At this stage it throws a MaxSerialisationDepthExceeded error.

It might not be 16 levels, but there is a limit.

Edit: It’s actually 7. Just because.

Code Tags!

Yes, I did Grozzier. It is better I explain what I am trying to do. TowerSystemManager has four type of towers in the game(it is a 2d tower defense). LevelTowerSystemController has two upgradable steps of the towers. So, I want the inspector shows up an array called towerType and inside this array another array called towerLevel.

I can see the array tower type on inspector, but I am not able to show the array towerLevel inside the array towerType.

remove monobehaviour inheritance of the second class.

1 Like

If you are strying to store just values you can use use string and values separated by char like, or / and when need you can read from strings, if you need to drag drop refferences then problem little different.

Thank you guys! The problem was the monobehaviour inheritance in LevelTowerSystemController. Now, it is working perfectly.