Question about EditorWindows and Serialization

Hello,

I’ve been diving into doing some really cool stuff with EditorWindows the last couple weeks, and mostly I’ve gotten them to do what I want. However, there’s one thing that sorta bugs me. I’ll try my best to explain.

I have a monobehaviour that contains an object. A public class. When I edit the values of this public class via an EditorWindow, everything is saved fine. However, if that public class has another public class as a member variable (or, at least as part of a List. I haven’t tried a straight member variable), the data that is edited in the EditorWindow isn’t saved the next time I open the window.

For example, I am making an AI editor. The EditorWindow, when active, holds a reference to an InstructionSet. This InstructionSet has a list of InstructionObject’s. While the EditorWindow is up, I can add, remove, and move the InstructionObjects in the view. Once I close the EditorWindow, though, everything goes away.

Is there something I’m doing wrong in the construction of my classes? Does Unity just not serialize 2 levels deep via the EditorWindow? Is there a way to fix it? One way around this I found on another project was to manually serialize all of the data into text files in my resources folder, then read them in whenever the EditorWindow was accessed. That works fine, but it’s messy, and I’d rather not do that here if possible.

Thanks!
Togi

I assume you have marked the problem class with the Serializable attribute?

Indeed I did. No dice. I’ve tried marking individual variables, too, just in case. But that felt like throwing spaghetti at the wall :stuck_out_tongue: