言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Undo.RecordObject

public static function RecordObject(objectToUndo: Object, name: string): void;

Description

RecordObjectが呼び出された後の変更点を記録します

ほぼ全てのプロパティの変更点はこの関数で記録することが出来ます。しかし、Transformの親の変更、コンポーネントの追加、オブジェクトの破棄はこの関数で記録することが出来ないので専用の関数を使用してください。 内部的にはオブジェクトの状態を一時的にコピーしフレームの最後で差分を取り、正確に何が変更されたかを検出します。変更されたプロパティはUndoスタックに保持されます。もし変更点がなにもない場合(バイナリの正確な比較は全てのプロパティで行われます)Undoスタックには保持されません。

        Undo.RecordObject (Selection.activeTransform, "Edit Transform");
Selection.activeTransform.position = Vector3(0, 0, 0);
	// Editor Script Side
	// Create a position Handle and make the target always look at the position handle.
	// This is an editor Script, this should go inside the Editor Folder.

	[CustomEditor (typeof(LookAtPoint))]
	class SnapshotTargetEx extends Editor {

		void OnSceneGUI () {
			
			LookAtPoint lookAtScript;

			EditorGUI.BeginChangeCheck ();
			Vector3 pos = Handles.PositionHandle(target.lookAtPoint, Quaternion.identity);
	        if (EditorGUI.EndChangeCheck ()) {
	        	Undo.RecordObject ("Move point");
	        	target.lookAtPoint = pos;

	        	// Make sure to call SetDirty otherwise the inspector will not know that the script properties were modified
	            EditorUtility.SetDirty (target);
	        }
	    }
	}