UnityEditor Undo
最重要的几项操作如下所述:
修改单个属性:
Undo.RecordObject (myGameObject.transform, "Zero Transform Position");
myGameObject.transform.position = Vector3.zero;
添加组件:
Undo.AddComponent<RigidBody>(myGameObject);
创建新的游戏对象:
var go = new GameObject();
Undo.RegisterCreatedObjectUndo (go, "Created go");
// 注意:不需要手动调用以下代码标记“脏”,会自动标记“脏”
//EditorUtility.SetDirty(go);
//EditorSceneManager.MarkSceneDirty(go.scene);
销毁游戏对象或组件:
Undo.DestroyObjectImmediate (myGameObject);
更改变换组件的父子化:
Undo.SetTransformParent (myGameObject.transform, newTransformParent, "Set new parent");