Objects created in EditorWindow do not persist after reloading project

Hello, I’ve looked through a few similar questions and didn’t find quite what I was looking for. There were a few questions whose solutions involved serializable fields and scriptable objects, but this felt a bit different.

Suppose I have a simple editor window that creates an object. The object will appear in the scene hierarchy correctly, but will not persist through closing / reloading the project scene.

If I manually change the object (rename, change parent, etc) using the Scene Editor itself, then the object will persist. I’m assuming there is a trivial solution for this, but have not had much time to investigate.


using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

public class CreateObjectWindow : EditorWindow
	// Keep track of what we've made
	private static List<GameObject> createdObjects;

	[MenuItem ("Window/CreateObject")]
	public static void OpenCreateObjectWindow ()
		// Make the window
		var window = EditorWindow.GetWindow (typeof(CreateObjectWindow));

		// Initialize the list
		createdObjects = new List<GameObject> ();

	void OnGUI ()
		// Simple single button
		if ( GUILayout.Button ("Create Object!") )
			// Make some empty object
			GameObject go = new GameObject ("made in editor!");
			createdObjects.Add (go);

			// Check if this is persistent (which it will not be)
			bool persists = EditorUtility.IsPersistent (go);
			Debug.LogFormat ("New object will persist? {0}", persists);