To allow the user to undo actions that are performed by a custom editor script you can use Undo.RegisterUndo

foreach (var item in Selection.transforms)
    Undo.RegisterUndo(item, "Move " +;
    var pos = item.position;
    pos = new Vector3(activeObject.transform.position.x, pos.y, pos.z);
    item.transform.position = pos;

Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume