Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Detecting object selection in scene view -- How?

Discussion in 'Scripting' started by Maker16, Aug 29, 2011.

  1. Maker16

    Maker16

    Joined:
    Mar 4, 2009
    Posts:
    779
    I am working on a tile painter tool for a hexmap. I have it mostly done, but I have hit one obstacle. I am using an editor window to let the user select the terrain to be painted. However, I do not know how to get it to detect when the user clicks on a hexagon in the scene view so I can use that event to change the clicked hexagon's material. I have tried detecting events in OnSceneGUI() in my editorwindow class, but none register. The only events it wants to detect are from within OnGUI(), and those are only events that occur within the editor window itself.

    How can I register, in my editorwindow object, that an object has been clicked in scene view and get the reference to that object?