ExecuteInEditMode : scene wants to be saved even after no change

While using @script ExecuteInEditMode to view my meshes and textures in edit mode, I am noticing that the scene wants to be saved even if no changes have been made. For example if I open the project, then change between scenes then there is no save prompt. But if I hit play then stop, the scene prompts to be saved. Why is this, and how could it affect my scene if I choose to save or not to save (that is the question!)

@script ExecuteInEditMode

(in function)

// Assign material UVs to mesh UVs
var theMesh : Mesh;
if (!EditorApplication.isPlaying) {
    theMesh = theObject.GetComponent(MeshFilter).sharedMesh as Mesh;
}
else {
    theMesh = theObject.GetComponent(MeshFilter).mesh as Mesh;
}

here is a package with 2 scenes included to show the issue, swapping between scenes is fine, hit play then stop and change scenes and there is a ‘Save Scene’ prompt : http://www.alucardj.net16.net/unityquestions/Editor_Issue.unitypackage

Edit : My editor problems are not only with this question. If anyone has information that could shed light on this, it would be greatly appreciated. I have similar problems with a mesh creator I wrote with it’s own editor script (can instantiate mesh in edit mode, while playing the verts are animated, but after stopping and restarting the verts don’t animate, whether I just re-assign the verts or reconstruct the mesh inc recalculateBounds/Normals, other cases where textures don’t update after play-stop-play). Creating these editor classes would be great and really handy for stage layouts instead of constantly hitting play and making minor adjustments.

this comes from my answer that can be found here : atlas tool like ngui - Questions & Answers - Unity Discussions

You said you don’t change anything, but your script has this line which is executed in Start:

theMesh.uv = theUVs;

which changes the uv array when you enter editmode since you use the “evil” ExecuteInEditMode.

A change doesn’t mean a certain value is different from the old one. This would also cause an object to be marked as dirty:

transform.position = transform.position;

If you don’t want this, don’t execute it in editmode.

If you want be able to “update” the uv settings in the editor, just add a context menuitem to execute this when you want it to update and not every time you enter editmode.

edit
Another thing: You shouldn’t use EditorApplication in a runtime script. You can’t build your project now, try it…

If you want to include editor specific stuff in a runtime script, make sure you use conditional compilation

#if UNITY_EDITOR
//Do editor stuff here
#endif