(gameObject.GetComponent(typeof(MeshFilter)) as MeshFilter).mesh;
…where gameObject is an imported 3D model, the inspector shows that gameObject’s mesh has been changed to an instance. If I quit the game, that instance mesh is deleted permanently and the original mesh is not restored, so gameObject now has an empty mesh forever unless I reimport it (restarting the game makes no difference).
This occurs even when I’m only reading the mesh data. I specifically do not want to write to it. Can anyone explain this behaviour? It doesn’t seem like it should be happening.
This is expected. Whenever you do a call to MeshFilter.mesh for the first time, it will create a copy for you, as to prevent modifications from applying to all the other instances of that mesh. It works similar to renderer.material.
This is also expected, for the same reasons.
This should not happen and is probably a bug. Does your application exit with an error? Often when an error occurs while the application shuts down, part of the in-game scene content will leak into the editor version of the scene.
If you’re only reading data from the mesh, you could use MeshFilter.sharedMesh instead. Be aware that any changes to this mesh are always permanent.