Custom Editor: Movement Gizmo disappears when using a GUI Group

Using Unity 4.1.5

I’ve created a custom editor class for one of my game objects. I want to have an editor UI render onto my scene window; however, when I create a GUI group to organize it correctly, the movement, rotation and scale gizmo disappears for the selected object.

I am not sure what is causing this to happen, but if I remove the GUI Group, it starts working again. Here is the code for the class. I’ve boiled down the problem to the GUI.BeginGroup call, so that’s all I’ve left in it.

using UnityEngine;
using UnityEditor;

[CustomEditor( typeof(MapPin))]
public class LevelEditor:Editor
{	
	
	void OnSceneGUI()
    {
		GUI.BeginGroup (new Rect (Screen.width - 200, Screen.height - 300, 150, 200));
		GUI.EndGroup();		
    }
}

Here is the more complete version of the class so you can see what I am going for:

using UnityEngine;
using UnityEditor;

[CustomEditor( typeof(MapPin))]
public class LevelEditor:Editor
{	
	private MapPin pin = null;	
	private bool linesEnabled = true;
	private GameObject[] objects = {};
	private GUIStyle newGuiStyle;	
	
	void OnEnable()
    {
        pin = (MapPin)target;            		
		newGuiStyle = new GUIStyle();
		newGuiStyle.fontSize = 20;
    }	
    
	void RePopulateObjects()
	{
		objects = GameObject.FindGameObjectsWithTag("MapPin");
	}
	
	void OnSceneGUI()
    {		
		if ( linesEnabled )
		{
			Handles.color = Color.cyan;				
			foreach (GameObject newObject in objects)
			{			
				Handles.Label(newObject.transform.position + Vector3.right*2,newObject.name, newGuiStyle);
				foreach (GameObject nextPin in newObject.GetComponent<MapPin>().nextPin)
				{	
					
					Handles.DrawLine(newObject.transform.position, nextPin.transform.position);	 						
				}
			}
		}
		
		GUI.BeginGroup (new Rect (Screen.width - 200, Screen.height - 300, 150, 200));
		GUI.Box (new Rect (0,0,150,200), "");	
		
		if (GUI.Button (new Rect (10,10,130,30), "Toggle Lines"))
		{
			linesEnabled = !linesEnabled;
		}
		
		if (GUI.Button (new Rect (10,50,130,30), "Repopulate Pins"))
		{
			RePopulateObjects();
		}
		
		GUI.EndGroup();		
    }	
}

Hi Moriak,

I believe that with OnSceneGUI(), you need to wrap your 2D GUI calls between Handles.BeginGUI() and Handles.EndGUI():

void OnSceneGUI()
{
    Handles.BeginGUI();
    		
    GUI.BeginGroup (new Rect (Screen.width - 200, Screen.height - 300, 150, 200));
    GUI.EndGroup();
    		
    Handles.EndGUI();
}

I hope that helps.

-Aaron