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

Custom collapsed component inspector

Discussion in 'Immediate Mode GUI (IMGUI)' started by AnKOu, Sep 22, 2020.

  1. AnKOu

    AnKOu

    Joined:
    Aug 30, 2013
    Posts:
    123
    Hi,

    I'm looking for drawing a custom icon on my scripts in the inspector.

    I don't want to use gizmo or assign an icon per script (I don't want to see the icon in the scene view etc.).

    What I do now is drawing an icon like that :
    Code (CSharp):
    1. GUI.DrawTexture(new Rect(16, -14, 15, 15), m_IconTexture, ScaleMode.ScaleToFit, false, 1f);
    In a custom editor.
    upload_2020-9-22_9-58-5.png


    The problem is that it is not working once the script is collapsed in the inspector.
    upload_2020-9-22_9-58-35.png


    So my question : is there a simple way to draw custom GUI stuff for collapsed component ?
     
  2. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    No simple way, I believe. The collapsed inspector is not using your custom inspector. You already ruled out assigning an icon to the script file which would show on the component and in the scene. The only other idea I would have would be to rewrite the inspector window (GameObject editor), but that doesn’t sound feasible just for an icon. I’d go with simply assigning the icon. ;)