Undo.RecordObject
[MenuItem("Example/Random Rotate")]
static void RandomRotate()
{
var transform = Selection.activeTransform;
if (transform)
{
//注释之后无法回退
Undo.RecordObject(transform, "Rotate " + transform.name);
transform.rotation = Random.rotation;
}
}