Select your preferred scripting language. All code snippets will be displayed in this language.
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.닫기
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.닫기
target 오브젝트를 표시합니다.
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 when modifying objects in scenes. This function is due to be deprecated in future versions of Unity.
Prior to this change, the command could be used as part of an editor script to mark an object as dirty and therefore requiring a save. If this command was used on an object in the scene, the scene file itself was also marked dirty. Therefore if you used an editor script which modified scene objects, and which included this function, you would be prompted to save your work when closing the editor or switching to a different scene.
Since the change, when the command is used on a scene object, the scene itself is not marked as dirty. This means you use an editor script which modifies scene objects, and the script relies on “SetDirty” to implicitly mark the scene as requiring a save, this no longer works. If you close the editor or switch to a different scene without manually saving, Unity would not give a save prompt, and your changes would be lost with no warning.
Instead, your editor scripts should use should use the SerializedObject functions if modifying properties in a custom inspector, or use Undo.RecordObject in other types of editor scripts prior to making changes to the object. This will mark the object's scene as dirty and provide an undo entry in the editor.''
Generally, unless you have a good reason not to, you should provide undo steps in your editor scripts. However if your script modifies items within a scene and specifically do not want to add an undo entry for your modification, you can use EditorSceneManager.MarkSceneDirty.
If you are using a custom editor to modify serialized properties on a component or an asset, you should be using SerializedObject.FindProperty, SerializedObject.Update, EditorGUILayout.PropertyField, and SerializedObject.ApplyModifiedProperties. This will mark the modified object and scene as 'dirty' and create Undo states for you.
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!
Unity에서는 데이터가 변경되어 있지만, 디스크에는 저장되지 않고 보존해야 하는 경우에 Dirty 플래그를 사용합니다.