[Custom editor] select parent gameobject when click child gameobject

Hi, i create a custom editor for create 2d pattern



  • child
  • child

I want when i click child gameobject in SceneView It will select parent gameobject. How can I do that?

Another question .How can i a change selection area of gameobject in Scene View.

Try this:

public class PlayerScript : MonoBehaviour {


The SelectionBaseAttribute will select your PlayerScript, when clicking any child.

I think this only works over one layer though, if you want the same behaviour when you’re clicking children of children, you’re going to need to do something custom. Maybe Unitys Selection helps you.

 // onChildSelect
 Selection.activeGameObject = Selection.activeGameObject.transform.parent;

(Found the above snippet here while searching for the same answer)

EDIT: Just figured [SelectionBase] does work over multiple layers. The only problem (for me) is that it’s still possible to select the child GameObject by clicking it twice. If that’s not a problem in your case forget about the second part of my response :wink: