Search Unity

How do I detect when X is selected in the Hierarchy and the Project windows for a custom Editor?

Discussion in 'Immediate Mode GUI (IMGUI)' started by majeric, Oct 6, 2015.

  1. majeric

    majeric

    Joined:
    Aug 17, 2010
    Posts:
    89
    I want to create an editor window that has a similar behaviour to the Animator window (like when you select a controller in the project window or select an animator in the hierarchy window, it updates the Animator editor window).

    I'll have a specific file type that when selected in the project will display my data visualization. Is there some sort of type/asset selection event registration?

    My google-fu is seriously failing me. It keep offering suggestions that aren't related to things I'm interested in. The problem is that I don't know the right words to ask google an intelligent question.

    Any direction would be amazing and appreciated
     
  2. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    Hey there,

    Anytime something is selected you have access to it.

    Code (CSharp):
    1. Selection.activeObject
    You can check that object for the type you are looking for and update the inspector to reflect this.

    Cheers,
     
  3. majeric

    majeric

    Joined:
    Aug 17, 2010
    Posts:
    89
    So you have to poll for selection then? In the Editor update loop?