https://docs.unity3d.com/ScriptReference/Undo.html
Modifying a single property:
Undo.RecordObject (myGameObject.transform, "Zero Transform Position"); myGameObject.transform.position = Vector3.zero;
Adding a component :
Undo.AddComponent<RigidBody> (myGameObject);
Creating a new game object:
var go = new GameObject (); Undo.RegisterCreatedObjectUndo (go, "Created go");
Destroying a game object or component:
Undo.DestroyObjectImmediate (myGameObject);
Changing transform parenting:
Undo.SetTransformParent (myGameObject.transform, newTransformParent, "Set new parent");