Scriptable Objects with serialized generic type

Hello,
Since with Unity 2020.1 we’re now able to serialize generic types, I was wondering if its possible to make the
ScriptableObject.CreateInstance<GenericScriptableObject<...>()> works too in order to not to have to implement a non-generic class before.

For exemple I have,

public class Variable<T> : ScriptableObject
{
    private T _value = default;
    public T Value
    {
        get => _value;
        set => SetValue(value);
    }

    public void SetValue(T value)
    {
        _value = value;
    }

}

and I want to be able to do

    public Variable<float> floatVariable;
    void Start()
    {
        floatVariable = ScriptableObject.CreateInstance<Variable<float>>();
    }

(For now ScriptableObject.CreateInstance<Variable>() just returns null)
Thanks !

Since it is brand-new capability, it seems like you might be the person best positioned to try it out, do some testing, evaluate it against your own specific criteria of “works for me!” and report back here if you like. I’ve never messed with that stuff myself.

1 Like

Sadly it does’nt work, I still need to inherit in a non generic class before being able to create a scriptable object :c