can I make an array of classes and have it list like an int array?

Silly question, but when you make an int array you get a neat little tab in the inspector that allows you to add int’s and edit them.

Is that possible to do with a whole class?

Like if I wanted to make an RPG and make stats/skills into classes and have each class cover the name, the level, the experience in that stat, etc…

Have you never learnt how to serialise plain C# classes? Unity - Scripting API: Serializable

Not out of the box, no, but you could make a “ClassReference” class, and a custom editor for those. However, you would have to decide how to display them, how to search for them, and how to ensure you aren’t just referring to any old random class but only ones that comply (say, by interface or base class). They’d likely be serialized by their name, and what happens if you rename a class after your ClassReference contains an older name? Lots of things to consider there.

Edit: It looks like spiney199 is talking about serializing whole instances of a class, while I am talking about whole classes. It’s always important to distinguish between the two.

I think Spiney and halley are actually answering different interpretations of your question…

And I think I have yet another completely different interpretation!

So I will answer what I think you are asking with this blurb:

ScriptableObject usage in RPGs:

Usage as a shared common data container:

I mean you’re kind of describing [SerializeReference]: https://docs.unity3d.com/ScriptReference/SerializeReference.html

As in if they wanted a base class with derived types, then SerializeReference is required to handle the polymorphic serialisation.

But they would need a custom inspector as Unity doesn’t have built in support for this (as far as selecting sub-types, but it can render fields that already have an reference).

Sorry, instances.

Also check out this, golden:

No, I meant a Unity wrapper for System.Type along the lines of this:

[Serializable] public class ClassReference
{
    public string fullyQualifiedTypeName;
    private System.Type type;
    private System.Type mustInherit;
    //...
}

with all the custom drawer code that would let you browse. Actually making instances of the type would be left as an exercise for the reader. Then you can have a list of “skill classes” with no instances, and when you earn the skill you instantiate state for it in the appropriate manner.

That’s definitely an idea. Though, [SerializeReference] can serialize from a System.Object type field, so I think that would be a substantially less flaky approach.

2023 and beyond also allows SerializeReference on generic types. So this would make for something that would actually workout of the box with no editor work required:

[System.Serializable]
public class ClassReference<T> where T : class, new()
{
    [SerializeReference]
    private T _reference = new T();
  
    public T Reference => _reference;
}

In hind sight the above code is superfluous unless you had a specific reason to have a generalised wrapper object.

Otherwise you can just serialise T directly.