Hi there,

I’m creating a serialized item database asset for storing objects. I’m managing several databases. I have an editor class for that database with a button that opens an EditorWindow to see all the items stored. So when I open my ItemDatabaseEditorWindow (extending EditorWindow) I want to open that window, but I need a way to say him to open that window passing “this” (the current database) as the object to edit (let’s say I’m scripting a windows that needs an object as a target. It makes no sense to open the window without it).

What I currently do is:

if (GUILayout.Button("Manage Items Of This Database", GUILayout.ExpandWidth(false))) {
    EditorWindow.GetWindow()<ItemEditorWindow>();
}

Thanks!

You could have an init function on the window instance, one that takes the database.

if (GUILayout.Button("Manage Items Of This Database", GUILayout.ExpandWidth(false))) 
{
    ItemEditorWindow editorWindow = EditorWindow.GetWindow()<ItemEditorWindow>();
    editorWindow.End();//If the window was alerady open, we should have something for clearing old data
    editorWindow.Init(this, databaseDataOrWhatever);
}