- Home /
Show custom List in Inspector?
I have tried using a usual `List` as a public class variable and the `List` shows up as one of the variables in the Inspector when the script is attached to a `GameObject`.
I created my own List called `MonsterList` by extending the `List` so that I could encapsulate some methods to my `MonsterList`. However, any public class variable of the type `MonsterList` doesn't show up in the Unity Inspector for me to set a size and drag to assign GameObjects to `MonsterList`.
So, how can I get a custom List to show up in the Unity's Inspector?
PS: I am using C#.
Answer by Voronoi · Dec 01, 2014 at 06:14 PM
You can do this by making your Custom class Serializable:
using UnityEngine;
using System.Collections;
[System.Serializable]
public class Item
{
public string itemName;
public int itemID;
[System.Serializable]
public enum ItemType
{
Mammal,
Bird,
Fish,
Insect,
Reptile
}
public Item (string name, int id)
{
itemName = name;
itemID = id;
}
public Item() {
}
}
Then, when you add this class to another script, even as a List it shows up in the Editor along with items added or subtracted.
In this example, the two public member variables are all that show in the inspector. What is the point of the enum which is never displayed and the constructor which is never called with arguments??
@LukeNukem44 There isn't too much of a point, except that if you also add a public variable of type "ItemType" in the public variables, you will then be able to have that as a dropdown in the Inspector Window.
Hope this answers your question - I do realize it's a bit late :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613081844im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Inspector cannot find script instance 1 Answer
c# enum wont show in inspector 3 Answers
Javascript and C#, different behaviour in inspector ? 1 Answer