2
0
Эх сурвалжийг харах

Fix C# issues in inspector-plugin tutorial (#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().
Mark Wilson 2 жил өмнө
parent
commit
872e5ff840

+ 7 - 5
tutorials/plugins/editor/inspector_plugins.rst

@@ -143,20 +143,22 @@ specifically add :ref:`class_EditorProperty`-based controls.
 
     public partial class MyInspectorPlugin : EditorInspectorPlugin
     {
-        public override bool _CanHandle(Variant @object)
+        public override bool _CanHandle(GodotObject @object)
         {
             // We support all objects in this example.
             return true;
         }
 
-        public override bool _ParseProperty(GodotObject @object, int type, string name, int hintType, string hintString, int usageFlags, bool wide)
+        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 (type == (int)Variant.Type.Int)
+            if (type == Variant.Type.Int)
             {
                 // Create an instance of the custom property editor and register
                 // it to a specific property path.
-                AddPropertyEditor(path, new RandomIntEditor());
+                AddPropertyEditor(name, new RandomIntEditor());
                 // Inform the editor to remove the default property editor for
                 // this property type.
                 return true;
@@ -283,7 +285,7 @@ followed by ``set_bottom_editor()`` to position it below the name.
             EmitChanged(GetEditedProperty(), _currentValue);
         }
 
-        public override void UpdateProperty()
+        public override void _UpdateProperty()
         {
             // Read the current value from the property.
             var newValue = (int)GetEditedObject().Get(GetEditedProperty());