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.
To draw the component correctly, create a script and inherit from SceneComponentDrawer
class. Then, override the DrawComponent()
method, like this:
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).
Last updated