So this is driving me insane.
- I have a MonoBehaviour called ObjectA
- Inside ObjectA is a custom list of ScriptableObjects: ObjectB (ListA of ObjectB)
- Would like to keep ListA full of references, no nulls
- User deletes ObjectB inside project, list now contains a null ref
- On selection change in EditorWindow, validate ListA, removing any nulls
simple right?
well, I’m not sure if during the selection change event unity is some weird thread, but trying to check ListA with any nulls is impossible. When logging the items I see the objects are null. But trying to determine whether that object actually is null isn’t working. e.g:
Debug.Log(obj) //null
if (obj == null) //always false
I’ve tried:
if (ReferenceEquals(obj, null)) //false
T item = list ?? default(T)
if (item == null) //false
I can’t get the type because the object is null! I get a null ref when trying to access. What is going on here? I’m going crazy