Unknown EditorApplication.SaveScene() errors

I'm trying to automate some things with unity. So far it works good, but I am concerned about these errors I get.

For example: 1) I call EditorApplication.OpenScene(); 2) Search for an object in the hierachy. 3) Call DestroyImmediate() on the object. 4) EditorApplication.SaveScene();

Everything works great until the SaveScene() call. Right after I call this, the unity console results in multiple entries of the following error:

"Failed to unpersist: Not loaded ID: 170180 FileID: 400001 UnityEditor.EditorApplication:SaveScene(String)"

Where the numbers are different almost every time. What I'm doing is looping through the scenes, deleting 1 or more objects from each scene and resaving them. Opening another scene, deleting, saving.

From what I can tell, it saves ok. But the errors clutter the console. As a possible workaround, I attempted to saving using MenuItem.ExecuteMenuItem( "File/Save Scene" );, but it doesn't recognize that particular menu entry.

When the script is done executing, it also throws similar errors but it is from "UnityEditor.DockArea:OnGUI()" instead.

Any ideas what any of these errors mean? I'm concerned that these errors are bad in ways I don't understand.


Probably you are trying to save scene with wrong file extension, correct one is [scene name].unity