Show/hide wireframe for the current selected object?

The wireframe selection makes it really hard to see the items being edited. A solution is to go in the preferences and modify the alpha, but this is something that requires a lot of work every time a modification is needed.

In the docs, there is a reference to SetSelectedWireframeHidden and a script at Unity - Scripting API: EditorUtility.SetSelectedWireframeHidden - unfortunately, this throws compilations errors left right and center.

// Shows / hides the wireframe of the objects in the scene.

class ShowHideWireFrame extends Editor {

	@MenuItem("Examples/Show WireFrame %s")
	static function Show() {
		for (var s : GameObject in Selection.gameObjects) {
			var rend = s.GetComponent.<Renderer>();
			
			if(rend)
				EditorUtility.SetSelectedWireframeHidden(rend, false);
		}
	}
	
	
	@MenuItem("Examples/Show WireFrame %s", true)
	static function CheckShow() {
		return Selection.activeGameObject != null;
	}
	
	
	@MenuItem("Examples/Hide WireFrame %h")
	static function Hide() {
		for (var h : GameObject in Selection.gameObjects) {
			var rend = h.GetComponent.<Renderer>();
			
			if(rend)
				EditorUtility.SetSelectedWireframeHidden(rend, true);
		}
	}
	
	
	@MenuItem("Examples/Hide WireFrame %h", true)
	static function CheckHide() {
		return Selection.activeGameObject != null;
	}
}

Has anyone been able to make this work?

I just ran into this problem, and my solution was to use GetComponentsInChildren instead of GetComponent on line 25. This is necessary because the renderers I was trying to disable wireframe for were children of the currently selected object. Modified code below:

using UnityEngine;
using UnityEditor;

public class ShowHideWireframeExample : EditorWindow
{
	[MenuItem( "Example/Show WireFrame %s" )]
	static void ShowWireframe( )
	{
		foreach( GameObject s in Selection.gameObjects )
		{
			Renderer rend = s.GetComponent<Renderer>( );

			if( rend )
				EditorUtility.SetSelectedWireframeHidden( rend, false );
		}
	}



	[MenuItem( "Example/Show WireFrame %s", true )]
	static bool ShowWireframeValidate( )
	{
		return Selection.activeGameObject != null;
	}



	[MenuItem( "Example/Hide WireFrame %h" )]
	static void HideWireframe( )
	{
		foreach( GameObject s in Selection.gameObjects )
		{
			Renderer[] rends = s.GetComponentsInChildren<Renderer>();

			foreach(Renderer rend in rends) {
				if( rend )
				EditorUtility.SetSelectedWireframeHidden( rend, true );
			}
		}	
	}



	[MenuItem( "Example/Hide WireFrame %h", true )]
	static bool HideWireframeValidate( )
	{
		return Selection.activeGameObject != null;
	}
}