AssetDatabase.CreateAsset() - Value cannot be null

I’m trying to use AssetDatabase.CreateAsset() but I always get the error

[Value cannot be null. Parameter name: asset]

which makes no sense since my Unity object isn’t null. Does my object class need any attributes to be able to be saved as an .asset file or am I misunderstanding how this works?

When the error tells you that the parameter is “null” than it is, logically. Keep in mind that most UnityEngine.Object derived types need special means to create an instance. Especially MonoBehaviour and ScriptableObject derived types. Those can not be created with “new”. If you do the object is considered dead / null. Like ilusja said, show the code where you actually “create” your object that you try to store as asset.

Here’s the answer. You can’t inherit from Unity object as it is part managed part native (C#/C++) and you don’t have access to the native part.