Editor script not updating hierarchy

I have the following editor script:

[MenuItem ("Tools/Center Universe on Object %g")]
	static void CenterUniverseOnObject () {
		Transform universe = GameObject.FindGameObjectWithTag("Universe").transform;
		Transform selection = Selection.activeTransform;

		print ("Moving " + universe.gameObject.name + " to " + -selection.position);

		universe.position = -selection.position;
		print (universe.position);

It is set to execute in edit mode.

When it runs, the print() lines report that the universe transform has moved to the correct spot, but it is not actually reflected in the editor. Moreover, if I add a line in this script to rename the object, the name updates permanently (as reported by the script) but doesn’t change in the hierarchy.


Moving the selection works just fine. If the object is a child of universe, I can go selection.parent.position = … and that works, but I seem to be getting the wrong object back when I look for it by Tag. I’m positive there’s nothing else visible with that tag.

OK I found the problem. There are hidden gameobjects in my hierarchy. I didn’t place them there. That’s annoying!