ScriptableObject-Architecture icon indicating copy to clipboard operation
ScriptableObject-Architecture copied to clipboard

SetValue to null causes NullPointerException

Open Haytam95 opened this issue 3 years ago • 0 comments

Hi, if I try to cleanup a Variable by setting null value, it raises NullPointerException.

I've fixed this issue changing in BaseVariable.cs:

 public override T SetValue(T value)
{
            T oldValue = _value;
            T newValue = base.SetValue(value);


            if(newValue != null && !newValue.Equals(oldValue)) // <---- This, null check
            {
                _event.Invoke(newValue);
            }

            return newValue;
}

Maybe it could be added to the code? :)

Haytam95 avatar Jul 01 '22 20:07 Haytam95