Legacy Documentation: Version 2017.1 (Go to current version)
言語English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorUtility.SetDirty

フィードバック

ありがとうございます

この度はドキュメントの品質向上のためにご意見・ご要望をお寄せいただき、誠にありがとうございます。頂いた内容をドキュメントチームで確認し、必要に応じて修正を致します。

閉じる

送信に失敗しました

なんらかのエラーが発生したため送信が出来ませんでした。しばらく経ってから<a>もう一度送信</a>してください。ドキュメントの品質向上のために時間を割いて頂き誠にありがとうございます。

閉じる

キャンセル

マニュアルに切り替える
public static function SetDirty(target: Object): void;
public static void SetDirty(Object target);

パラメーター

target The object to mark as dirty.

説明

Marks target object as dirty. (Only suitable for 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.''

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.

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 internally uses the dirty flag to find out when assets have changed and need to be saved to disk.