Hello everyone, I need some help in unity custom editors, so I am creating a map editor for a 2D game. I made a EditorToolbar
class for toolbar that is an extension the GUI.Toolbar(...)
function by holding the items list and showing the toolbar with the ShowToolbar()
function and it is intended for general purpose:
[System.Serializable]
public class EditorToolbar {
public List<IEditorToolbarItem> items;
public EditorToolbar() {
items = new List<IEditorToolbarItem>();
}
public void AddToolbarItem(IEditorToolbarItem item) { ... }
public void ShowToolbar() { ... }
}
where IEditorToolbarItem
is an interface that has a UseItem()
function, I want the editor to not clear the items
list when the the assemblies reload (entering playmode or changing code). When I looked in net, it talks about serialized objects and fields, since it is not possible to serialize interfaces, I tried to make them as a class but after that the items list only holds reference to the basic class and empty UseItem()
function instead of the inherited classes one. I can’t find a way to fix that, so can anyone clarify me what should I do to fix the problem ?