- Home /
How do I make a public array of arrays appear in the inspector?
If you make an array of textures like this:
public Texture2D[] lightattacklist;
A folder appears in the inspector, which you can drag textures into to assign them after setting the sizes :)
However, I need to make an array of arrays of textures, like this:
public Texture2D[][] allanimationslist;
This creates nothing in the inspector. How do I make the inspector give me a folder of folders full of textures? If impossible, how else could I assign textures within the script?
Thanks :D
Answer by Herman-Tulleken · Jul 26, 2011 at 07:21 AM
As simple workaround is to define a wrapper class for an array of lists, like this:
[Serializable]
public class TextureList
{
public Texture2D[] textures;
}
public TextureList[] textureLists;
Not quite as convenient, but it works.
This question was answered four years ago, so things might have changed a fair bit.
Actually, if you declare 'using System;' at the top, you may use plain '[Serializable]'. I like that way better
Not only this does not answer the question at all, as it is also partially wrong.
Please remove the answer and write it as a comment to the answer above, which was what I believe you meant to do in the fist place.
If i place a game objects in the arrays, how can i access its properties like it's transform?
This solution works perfectly and I thank @Herman-Tulleken for this. However I had to struggle to access the elements with this approach so this is the solution I found on another post here. https://answers.unity.com/questions/231715/is-there-any-way-to-view-2d-arrays-in-the-inspecto.html
Basically you simply need to call
textureList[row index].textures[column index]
e.g.
textureList[2].textures[5]
will access 3rd array and then will access its 6th element.
Your answer
Follow this Question
Related Questions
Public Array with a class not showing in Inspcetor 1 Answer
Array elements are empty in the inspector? 1 Answer
How to show an array of custom objects in Inspector? 2 Answers
Inspector Doesn't Update Array Elements When Updated In Array Constructor 1 Answer
Calling an object from Array/List 1 Answer