# Custom component Inspectors

To get full control over how a component draws its presence in the Inspector, you can implement a custom `PropertyDrawer` script for it.

{% hint style="info" %}
If you are unfamiliar with Property Drawers, check out [the official Unity documentation](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/PropertyDrawer.html) for them.
{% endhint %}

To draw the component correctly, create a script and inherit from `SceneComponentDrawer` class. Then, override the `DrawComponent()` method, like this:

```csharp
using SuperScenes.Editor.CustomEditors;
using UnityEditor;
using UnityEngine.UIElements;

namespace SuperScenes.Editor
{
    [CustomPropertyDrawer(typeof(EnemyData))]
    public class EnemyDataPropertyDrawer : SceneComponentDrawer
    {
        protected override VisualElement DrawComponent(SerializedProperty property)
        {
            VisualElement inspector = base.DrawComponent(property);

            inspector.Add(new HelpBox("This box has been added by a custom PropertyDrawer.",
                HelpBoxMessageType.Info));

            return inspector;
        }
    }
}
```

In the method, you can create a completely new editor from scratch, or you can leverage `base.DrawComponent(property)` to still draw the original Inspector and add elements to it (like in the example above).

{% hint style="info" %}
To create a custom Property Drawer for Scene Components, you must use [UI Toolkit](https://docs.unity3d.com/6000.1/Documentation/Manual/UIElements.html).

However, you can still return an `IMGUIContainer` element from your override of `DrawComponent()` , and implement your UI in `OnGUI`. Check out Unity's own [IMGUIContainer documentation](https://docs.unity3d.com/Manual/UIE-uxml-element-IMGUIContainer.html).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tools.continis.io/superscenes/advanced/custom-component-inspectors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
