Skip to content

Commit 872e5ff

Browse files
authored
Fix C# issues in inspector-plugin tutorial (godotengine#7223)
* Fixed C# EditorInspectorPlugin _CanHandle parameter type Updated Inspector Plugin tutorial to reflect that C#'s EditorInspectorPlugin::_CanHandle() takes a GodotObject, not a Variant. * Eliminated horizontal scroll in C# for inspector-plugin tutorial Put a line-break and indentation to avoid horizontal scrolling in the displayed code. * Fixed _ParseProperty() method signature and undeclared variable Changed example code for EditorInspectorPlugin::_ParseProperty(): * Fixed method signature * Use new enum type of parameter for comparison instead of int. * Use "name" parameter as property-identifying argument to AddPropertyEditor() instead of undeclared variable * Fixed override method name in EditorProperty example Updated example to use virtual method _UpdateProperty() instead of non-virtual method UpdateProperty().
1 parent bd77af8 commit 872e5ff

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tutorials/plugins/editor/inspector_plugins.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,22 @@ specifically add :ref:`class_EditorProperty`-based controls.
143143

144144
public partial class MyInspectorPlugin : EditorInspectorPlugin
145145
{
146-
public override bool _CanHandle(Variant @object)
146+
public override bool _CanHandle(GodotObject @object)
147147
{
148148
// We support all objects in this example.
149149
return true;
150150
}
151151

152-
public override bool _ParseProperty(GodotObject @object, int type, string name, int hintType, string hintString, int usageFlags, bool wide)
152+
public override bool _ParseProperty(GodotObject @object, Variant.Type type,
153+
string name, PropertyHint hintType, string hintString,
154+
PropertyUsageFlags usageFlags, bool wide)
153155
{
154156
// We handle properties of type integer.
155-
if (type == (int)Variant.Type.Int)
157+
if (type == Variant.Type.Int)
156158
{
157159
// Create an instance of the custom property editor and register
158160
// it to a specific property path.
159-
AddPropertyEditor(path, new RandomIntEditor());
161+
AddPropertyEditor(name, new RandomIntEditor());
160162
// Inform the editor to remove the default property editor for
161163
// this property type.
162164
return true;
@@ -283,7 +285,7 @@ followed by ``set_bottom_editor()`` to position it below the name.
283285
EmitChanged(GetEditedProperty(), _currentValue);
284286
}
285287

286-
public override void UpdateProperty()
288+
public override void _UpdateProperty()
287289
{
288290
// Read the current value from the property.
289291
var newValue = (int)GetEditedObject().Get(GetEditedProperty());

0 commit comments

Comments
 (0)