- Home /
Display custom names for array
I have a class that is a wrapper for resources in my game. It consists of a int array that holds the values. I would now like to display the int array in the inspector with each element named according to its enum Name, instead of Element 0 etc...
public enum Ware {Holz,Bretter,Stein,Weizen,Mehl,Nahrung,Eisenerz,Kupfererz,Kohle,Eisen,Kupfer,Edelsteine,END};
[System.Serializable]
public class WarenContainer {
public int[] Values = new int[12];
}
Answer by hexagonius · Sep 25, 2017 at 02:00 AM
You should find everything here:
http://catlikecoding.com/unity/tutorials/editor/custom-list/
I tried to do it that way using PropertyDrawer as my custom class doesn't inherit from monobehavior.
Unfortunately this causes ArgumentException: Getting control x's position in a group with only x controls when doing Redraw exceptions From other answers this happens when you change the gui elements between different runs of the OnGui function, but I am not changing the number of property fields anywhere.