private void ActivateLayer(ElementsLayerSwitcher switcher, int newLayer) { Undo.RecordObject(switcher, "Changed Active Layer"); switcher.Refresh(); switcher.ActivateLayer(newLayer); Undo.undoRedoPerformed += OnUndo; }