Hi
This is the inspector
As you can see the answer in the forum doesn’t work if there is an array inside an array of class
Code
[System.Serializable]
public class DragonsClass
{
[NamedArrayAttribute(new string[] { "Neutral", "Happy", "Sad" })]
public string[] Annswer0;
[NamedArrayAttribute(new string[] { "Neutral", "Happy", "Sad" })]
public string[] Annswer1;
}
public DragonsClass[] DragonsInLevel;
Thank you
First of all that forum thread is a discussion and it has been pointed out several times that in the specific case that was mentioned it’s actually a bad idea to use an array if the array should contain a fix amount of elements. You only want to use an array if you have a variable element count in which case hardcoded element names are just wrong.
The property drawer that JohnnyA has posted is a very simple implementation and yes, it does not support nested arrays since it reads the current element index from the property path and he simply grabs the first index it encounters. This could be improved but as already mentioned it’s the wrong approach.
Also, as it has been mentioned in the thread you’ve linked, Unity does automatically rename the element names if the element represents a class / struct and has a string variable as first element. The element will take the content of that first string variable. That way you can create an actual dynamical array / list.