Inspector and Custom Classes

I’m totally stumped on a scenario which I’m positive I’ve seen people use successfully:

I have a MonoBehaviour which has a public List.

MyClass is a custom class which inherits from nothing. It probably looks something like this:

public class MyClass
{
public GameObject prefabRef;
public int counter;
public string message;
public bool log;
}

When I select the GameObject containing the MonoBehaviour with the public List, the list does not appear at all in the inspector.

I’ve seen some screenshots and demo videos and such where people have these collections of custom classes inside a MonoBehaviour which:

  1. Appear in the inspector.

  2. Increasing the size of the collection seems to automatically populate the collection with new custom type instances.

  3. Each element is expandable and editable.

So to use my example, I’m trying to get the public List to appear, and increasing the size of the list should create these instances of MyClass which are then entirely accessible and editable in the inspector.

I’m also sure at least some of these examples are not using custom OnInspectorGUI scripts.

Any pointers on where to look?

facepalm

I posted a thread recently mocking how often I struggle to find an answer to a problem, only to post on this forum and then find the solution myself almost immediately afterwards.

All I needed to do was put the [System.Serializable] directive-thingy (whatever they’re called) before the MyClass declaration.