Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

An editor script that scrolls the inspector to show a specific component.

Discussion in 'Scripting' started by Nifflas, Dec 2, 2014.

  1. Nifflas

    Nifflas

    Joined:
    Jun 13, 2013
    Posts:
    118
    I'm working on an event system. Each event links to a MonoBehaviour on a different script, and for allowing the user to quickly navigate the signal path, I need a button that selects the GameObject the linked MonoBehaviour is on, then scrolls the inspector so that it shows that MonoBehaviour.

    Selecting the GameObject so that the inspector shows its components was easy, but I have no idea how to make the inspector scroll to the desired component. Been searching the API and googling with no luck.
     
    Last edited: Dec 2, 2014
  2. Nifflas

    Nifflas

    Joined:
    Jun 13, 2013
    Posts:
    118
    Update: I tried out the Assembly Browser. New territory for me. Looks like the answer is in EditorUtility.InspectorWindow, so I suppose now is as good time as any to learn those reflection tricks. :)
     
  3. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    930
    @Nifflas I'm trying to accomplish the same thing. Did you find out how to do it?
     
  4. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,184
    Try this:
    https://docs.unity3d.com/ScriptReference/Highlighter.Highlight.html

    Not sure how it works for every usecase, but I've managed to highlight a specific inspector field on a custom script, within a list and have it automatically scroll there to show it.
     
  5. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    930
    @Xarbrough Thanks! That seems to be exactly what I need! ;)