chore: change to safely access nameof(_serviceScope)
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
#if TOOLS
|
||||
using Godot;
|
||||
using GodotHostTest.addons.godot_di;
|
||||
|
||||
namespace GodotHostTest.GodotDI;
|
||||
|
||||
[Tool]
|
||||
public partial class GodotDI : EditorPlugin
|
||||
{
|
||||
private ScopeInspectorPlugin? _plugin;
|
||||
private ServiceSource.ScopeInspectorPlugin? _plugin;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
GD.Print("Initializing Godot DI");
|
||||
_plugin = new ScopeInspectorPlugin();
|
||||
_plugin = new ServiceSource.ScopeInspectorPlugin();
|
||||
AddInspectorPlugin(_plugin);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@ using GodotHostTest.addons.godot_di;
|
||||
|
||||
namespace GodotHostTest.GodotDI;
|
||||
|
||||
public partial class ServiceSource
|
||||
{
|
||||
// it's inside ServiceSource so that it can safely access nameof(_serviceScope)
|
||||
public partial class ScopeInspectorPlugin : EditorInspectorPlugin
|
||||
{
|
||||
public override bool _CanHandle(GodotObject @object)
|
||||
@@ -19,7 +22,7 @@ public partial class ScopeInspectorPlugin : EditorInspectorPlugin
|
||||
PropertyUsageFlags usageFlags, bool wide)
|
||||
{
|
||||
// We handle properties of type integer.
|
||||
if (name != "_serviceScope") return false;
|
||||
if (name != nameof(_serviceScope)) return false;
|
||||
// Create an instance of the custom property editor and register
|
||||
// it to a specific property path.
|
||||
AddPropertyEditor(name, new ScopePickerEditor());
|
||||
@@ -28,4 +31,6 @@ public partial class ScopeInspectorPlugin : EditorInspectorPlugin
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user