This commit is contained in:
redglow
2026-07-17 15:14:51 +02:00
parent 5ad3af84b2
commit d689e9ea1d
9 changed files with 362 additions and 62 deletions
@@ -0,0 +1,30 @@
#if TOOLS
using Godot;
namespace GodotHostTest.GodotDI.Editor;
// it's inside ServiceSource so that it can safely access nameof(_serviceScope)
public partial class ScopeInspectorPlugin : EditorInspectorPlugin
{
public override bool _CanHandle(GodotObject @object)
{
var result = @object.IsServiceSource();
return result;
}
public override bool _ParseProperty(GodotObject @object, Variant.Type type, string name, PropertyHint hintType,
string hintString,
PropertyUsageFlags usageFlags, bool wide)
{
// We handle properties of type integer.
if (name != nameof(ServiceSource.PropertyName._serviceScope)) return false;
// Create an instance of the custom property editor and register
// it to a specific property path.
AddPropertyEditor(name, new ScopePickerEditor());
// Inform the editor to remove the default property editor for
// this property type.
return true;
}
}
#endif