Custom editor makes inspector view act weirdly.

Hello,

I’ve created a script that ended up making my inspector view looking from the right way to a really weird way (pics bellow) :

Before

4747-goodunity.png

After

4748-brokenunity.png

Needless to say I don’t want this behavior.
Where did I screw up so badly ?

Here is my custom Script code

[CustomEditor(typeof(GameObject))]
public class AutoSnapObject : Editor {

	
	
	void OnSceneGUI()
	{
		
		if (Event.current.type == EventType.KeyDown && Event.current.character=='p')
	    {
			
	    	RaycastHit hit;
			
			GameObject go = ((SnapTarget)GameObject.FindObjectOfType(typeof(SnapTarget))).gameObject;
			if (go==null)
			{
				Debug.Log("no snap target found");
				return;
			}
			if (go==target)
			{
				Debug.Log("currently selected object is the snap target");
				return;
			}
				
			
		
			Collider coll = go.GetComponent<Collider>();
			if (coll==null)
			{
				Debug.Log("no collider detected at the snap target");
				return;
			}
			GameObject targetObject = (GameObject) target;
			if (targetObject==null)
			{
				Debug.Log("invalid cast");
				return;
			}
			Vector3 normalizedDir = coll.transform.position-targetObject.transform.position;			
			if (normalizedDir.magnitude <0.04f)
				return;
			
			normalizedDir=Vector3.Normalize(normalizedDir);
			
			coll.Raycast(new Ray(targetObject.transform.position,normalizedDir),out hit,Mathf.Infinity);
			
			targetObject.transform.position=hit.point + hit.normal*0.03f;
			targetObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
	        
	
	
	        Event.current.Use();
	    }		
		
	}
	
}

Ok Solved it by changing

[CustomEditor(typeof(GameObject))]

to

[CustomEditor(typeof(Transform))]

Anyone has any clues as to why using GameObject is causing this behavior to happen ?