When using Godot (4+), in order to create custom editors (inspectors, property drawers and more), you need to write a new EditorPlugin that handles all of them (or one each), which can be slow and repetitive especially if you manage or create multiple projects.
This package makes it easier to create custom inspectors, drawers and more, by just inheriting from specific classes (inspired from the [CustomEditorOfType(typeof(TClass))] workflow of Unity).
To create a custom inspector, simply have a class in your code inherit from "Febucci.EditorUtils.CustomInspectorBase<TObject>", where TObject is the class you'd like to apply the inspector to.
// example script
[Tool] // required for now
public partial class YourScript : Node { }
// you only need this to have a custom inspector on "YourScript" node
#if TOOLS
public partial class YourScriptDrawer : CustomInspectorBase<YourScript>
{
public override bool _ParseProperty(GodotObject @object, Variant.Type type, string name, PropertyHint hintType, string hintString, PropertyUsageFlags usageFlags, bool wide)
{
// do stuff here [...]
return base._ParseProperty(@object, type, name, hintType, hintString, usageFlags, wide);
}
}
#endifTo create a custom drawer that is applied to attributes (e.g. [ReadOnly]), inherit from "Febucci.EditorUtils.AttributeDrawerBase"
// example attribute
public class ReadOnlyAttribute : Attribute { }
// you only need this
#if TOOLS
public partial class ReadOnlyDrawer : AttributeDrawerBase<ReadOnlyAttribute>
{
protected override Control GetPropertyEditor(Variant.Type type, string name, PropertyHint hintType, string hintString, PropertyUsageFlags usageFlags, bool wide, object value)
{
// create your control node here
// return ....
}
}
#endif...more helpers coming in the future!
Requirements
- This addon requires the 'mono' version of Godot (you need C#)
Install:
- Copy the "addons/FebucciEditorUtils" folder in your godot project
- Build the project once
- Enable the plugin from the "project -> project settings -> plugins" tab.
Created by Febucci Team:
- Discover our game development tools.
- Read our learning notes, tutorials and more.
- Join our Discord Server.
Thanks!
If you want to contribute
- Fork the project.
- Create your own feature branch.
- Commit and push your changes to GitHub.
- Create a new pull request (with a description that helps us review faster).
More information about contributing here: https://github.com/firstcontributions/first-contributions