ScriptableObject.CreateInstance returning null value.

I’m guessing it’s because of “AddAssetSetWindow”, but I don’t know why that would be.

public abstract class AssetManagerWindow<T> : EditorWindow where T : IAsset
{
    public AssetManagerWindow()
    {
        var a = ScriptableObject.CreateInstance<AddAssetSetWindow<T>>();
        //a is null...
    }
}

public class AddAssetSetWindow<T> : EditorWindow where T : IAsset
{
}

The problems i see here are:

  • classes derived from ScriptableObject need to be defined in a seperate file where the filename matches the classname (just like MonoBehaviours).
  • Such classes can’t be generic, never. You can have a generic base class, but the actual class(es) that should be created have to be non generic. Otherwise CreateInstance wouldn’t work with a string that contains the classname since a generic type can’t be described with a type-string.
  • EditorWindows are usually created with GetWindow. If you want you can use CreateInstance but don’t forget to call a Show method..