- Home /
[Solved] Unity EditorWindow Serialization Problem.
I have started building an editor tool that will allow me to place objects in the scene. Starting out, I am going to drag objects to the tool and they will be placed in a Dictionary.
I want this editor to Serialize it's data so it is stored between going to play and back, as well as when I reset Unity, this question pertains to the former, but any help with the latter would be great as well.
I have 4 classes:
PlaceObject : EditorWindow - This is the EditorWindow class.
PlaceObjectData: ScriptableObject - This is the object that holds all the data used by the EditorWindow.
SerializableNestedList: ScriptableObject - This is a List that can hold a list, because Unity does not Serialize nested lists.
SerializableDictionary: ScriptableObject - This is a Serializable Dictionary, that should keep O[1], while being Serializable by Unity by matching it with two lists.
The problem I am running into is that in the PlaceObject class, line 56 throws a NullReferenceException on m_data.m_objects. This is because PlaceObjectData on line 23, returns null, I am not sure why that is.
I am sure that there are other problems with this, as serialize is not something I have worked with at all.
If you can help me figure out why this is happening, or point out any other issues/flawed logic please let me know.
Edit:
So after researching the problem, ScriptableObject.CreateInstance cannot handle generic's I have entirely rewritten the code above and removed all generics that ScriptableObject.CreateInstance.
It is not as pretty to be sure, but it works, and I learned how to be use scriptable objects. I mainly used this resource to rewrite what I had done, which is found Here