Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How to inject custom UI elements into existing IMGUI editors?

Discussion in 'Immediate Mode GUI (IMGUI)' started by AxonGenesis, May 18, 2024.

  1. AxonGenesis

    AxonGenesis

    Joined:
    Jun 24, 2016
    Posts:
    100
    Is there a way I could inject or modify UI elements in built-in editors, such as the Transform component?

    Here's a mockup adding some button icons and a color overlay as an example:
    upload_2024-5-18_11-30-53.png

    So far, the only way I have found is to create my own custom editors for each component type. This essentially replaces the built-in editor with my own version.

    Code (CSharp):
    1.  
    2. [CustomEditor(typeof(Transform))]
    3. public class TransformOverride : Editor
    4.  
    The problem with this approach is that it replaces built-in functionality and is too likely to cause problems or change the behavior from what the user expects. It would also be a lot of work to do this for every component type.

    Is there some other way I could draw over the inspector and use reflection to detect property fields? I'd want to do this for all components on the object and inject UI for any compatible fields.