几天前,UE说有时候他们在编辑器内改了prefab但是没有保存,我查了一下,发现项目中Editor中用到了这个接口用来将Scene SetDirty,之前很多地方都是这样用,也没觉得有什么问题,后来仔细查了一下,发现在Unity5.3之后,这个接口使用的场景变了,具体可以在Unity的官方文档中看到:地址



Marks target object as dirty. (Only suitable for non-scene objects).(将目标Object标记为Dirty(仅适用于non-scene objects))

NOTE: ''Prior to Unity 5.3, this was the primary method of marking objects as dirty. From 5.3 onwards,
with the introduction of Multi-Scene Editing, this function should no-longer be used for modifying objects in scenes. Instead, you should use Undo.RecordObject prior to making changes to the object.
This will mark the object's scene as dirty and provide an undo entry in the editor.''
在Unity 5.3之前,这是将对象标记为脏的主要方法。 

If you are modifying files within a scene and specifically do not want to add an undo entry for your modification, you should use EditorSceneManager.MarkSceneDirty

If you are using a custom editor to modify serialized properties on a component or an asset, you should be using [pSerializedObject.FindProperty]], SerializedObject.Update, EditorGUILayout.PropertyField, and SerializedObject.ApplyModifiedProperties. This will mark the modified object as 'dirty' and create Undo states for you.

如果你使用自定义编辑器修改component或asset的序列化属性,应该使用[pSerializedObject.FindProperty]],SerializedObject.Update,EditorGUILayout.PropertyField和SerializedObject.ApplyModifiedProperties。 这会将修改的对象标记为“脏”并为你创建撤消状态。

Therefore the only remaining situation in which you should use this function is if you are modifying non-scene objects via some other means, and specifically do not want create an undo entry for your modification. This is rare, and unless you're very sure about requiring this, you probably shouldn't be using this command!
因此,你应该使用此功能的唯一剩余情况是,你是否通过其他方式修改非场景对象,并且不希望为修改创建撤消条目。 这很少见,除非你确定要求这样做,否则你可能不应该使用这个命令!