お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
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.
Closeダーティとして target
オブジェクトをマークします
Unityではデータが変更されているが、ディスクには保存されておらず保存する必要がある場合にダーティフラグを使用します。 例えば、PrefabのMonoBehaviourやScriptableObject変数を変更する場合はUnityのシステムに値が変更されたことを伝えなければいけません。 Unityが用意しているコンポーネントは内部でプロパティが変更した時にこの関数が呼び出されています。 ユーザー独自で作成したMonoBehaviour または ScriptableObject は自動でSetDirtyを呼び出してはいないので値を変更した場合は呼び出す必要があります。
#pragma strict // This example shows a custom inspector for an // object "MyPlayerEditor", which has two variables, speed and ammo. @CustomEditor(MyPlayer) class MyPlayerEditor extends Editor { function OnInspectorGUI() { var targetPlayer = target as MyPlayer; EditorGUILayout.LabelField ("Some help", "Some other text"); GUI.changed = false; targetPlayer.speed = EditorGUILayout.Slider ("Speed", targetPlayer.speed, 0, 100); if (GUI.changed) EditorUtility.SetDirty(targetPlayer); } }