Skip to content

Commit 47e6959

Browse files
committed
Added new example, documentation changed
1 parent 1447271 commit 47e6959

File tree

4 files changed

+31
-34
lines changed

4 files changed

+31
-34
lines changed

README.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,33 @@ Makes it easier to add custom inspector controls to nodes.
1010

1111
Download the project and copy the addon folder into your godot project.
1212

13-
Go to Project Settings > Plugins, and enable Extendable Inspector.
13+
Go to Project Settings > Plugins, and enable Extendable Inspector (C#).
1414

1515
# Quick Start / Tutorial
1616

1717
Let's add a button that prints the node name in godot's output:
18-
- Choose the node that should have this control, make sure its script has the `@tool` annotation at the beginning, [this allows it to run code while in the editor](https://docs.godotengine.org/en/stable/tutorials/plugins/running_code_in_the_editor.html).
18+
- Choose the node that should have this control, make sure its script has the `[Tool]` attribute at the class declaration, [this allows it to run code while in the editor](https://docs.godotengine.org/en/stable/tutorials/plugins/running_code_in_the_editor.html).
1919
![image](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/11432672/7c84f2c1-e64f-40ee-a3f0-ef6f858eb78f)
20-
- Define a method called `_extend_inspector_begin` that receives a parameter, let's call that parameter `inspector`. If you want, you can type it as `ExtendableInspector` to get some autocomplete features:
20+
- Define a method called `ExtendInspectorBegin` that receives a parameter, let's call that parameter `inspector`. If you want, you can type it as `ExtendableInspector` to get some autocomplete features:
2121
![image](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/11432672/65f90976-adeb-4607-9d58-46fa214c2f0f)
22-
- Create a button that when pressed, it prints the node's name. Then, simply add it to the inspector with `inspector.add_custom_control(a_control)`. You will have to unfocus the node and focus it again for the button to appear:
22+
- Create a button that when pressed, it prints the node's name. Then, simply add it to the inspector with `inspector.AddCustomControl(ourNewControl)`. You will have to unfocus the node and focus it again for the button to appear:
2323
![image](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/11432672/2d4e62ef-7dcf-4cc5-b74c-c26bde55c70a)
2424

2525
Here's the entire code in case you want to try it out:
2626

27-
```godot
28-
@tool
29-
30-
extends Node2D
31-
32-
func _extend_inspector_begin(inspector: ExtendableInspector):
33-
var button = Button.new()
34-
button.text = "Say your name"
35-
button.pressed.connect(func(): print(self.name))
36-
37-
inspector.add_custom_control(button)
27+
```csharp
28+
using Godot;
29+
30+
[Tool]
31+
public partial class SayYourName : Node2D {
32+
public void ExtendInspectorBegin(ExtendableInspector inspector) {
33+
Button button = new() {
34+
Text = "Say your name"
35+
};
36+
button.Pressed += () => GD.Print(Name);
37+
inspector.AddCustomControl(button);
38+
}
39+
}
3840
```
3941

4042

@@ -46,34 +48,29 @@ The supported methods are analogous to methods that can be defined in an `Editor
4648
https://docs.godotengine.org/en/latest/classes/class_editorinspectorplugin.html#class-editorinspectorplugin-method-add-property-editor-for-multiple-properties
4749

4850
These methods are:
49-
```godot
50-
void _extend_inspector_begin(inspector: ExtendableInspector)
51+
```csharp
52+
void ExtendInspectorBegin(ExtendableInspector inspector)
5153
```
5254
Allows adding controls at the beginning of the inspector.
5355

54-
```godot
55-
void _extend_inspector_end(inspector: ExtendableInspector)
56+
```csharp
57+
void ExtendInspectorEnd(ExtendableInspector inspector)
5658
```
5759

5860
Allows adding controls at the end of the inspector.
5961

60-
```godot
61-
bool _extend_inspector_category(inspector: ExtendableInspector, category: String)
62+
```csharp
63+
void ExtendInspectorCategory(inspector: ExtendableInspector, string category)
6264
```
6365

6466
Allows adding controls at the beginning of a category in the property list for object.
6567

66-
```godot
67-
void _extend_inspector_property(inspector: ExtendableInspector, object: Object, type: int, name: String, hint_type: int, hint_string: String, usage_flags: int, wide: bool)
68+
```csharp
69+
bool ExtendInspectorProperty(ExtendableInspector inspector, Variant.Type type, string name, PropertyHint hintType, string hintString, PropertyUsageFlags usageFlags, bool wide)
6870
```
6971

7072
Allows adding property-specific editors to the property list for object. The added editor control must extend `EditorProperty`. Returning `true` removes the built-in editor for this property, otherwise allows to insert a custom editor before the built-in one.
7173

7274
## Examples
7375

7476
Examples can be found in the [example folder](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/tree/godot-4/addons/extendable_inspector_for_cs/example)
75-
76-
## Utils
77-
78-
This plugin has a core folder that adds the functionality to let you extend the inspector with any custom control you define from your own scripts.
79-
Apart from that, there's a `utils` folder that defines some already made controls that can be added to the inspector.

addons/extendable_inspector_for_cs/example/ChangeRandomColor/ChangeRandomColor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Godot;
22

3-
[GlobalClass, Tool]
3+
[Tool]
44
public partial class ChangeRandomColor : Node {
55
public void ChangeToRandomColor() {
66
CsgBox3D box = GetNode<CsgBox3D>("CSGBox3D");

addons/extendable_inspector_for_cs/example/SpiralCurveCreator/SpiralCurveCreator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Godot;
22

3-
[GlobalClass, Tool]
3+
[Tool]
44
public partial class SpiralCurveCreator : Node3D {
55
[Export] public float Radius { get; set; } = 5;
66

@@ -11,7 +11,7 @@ public partial class SpiralCurveCreator : Node3D {
1111
Path3D path;
1212

1313
public void DrawEspiral() {
14-
Curve3D curve = GetPath().Curve;
14+
Curve3D curve = GetPathNode().Curve;
1515
curve.ClearPoints();
1616
float angle = 0;
1717
float y = 0;
@@ -26,7 +26,7 @@ public void DrawEspiral() {
2626
}
2727
}
2828

29-
private Path3D GetPath() {
29+
private Path3D GetPathNode() {
3030
if (!HasNode("Path3D")) {
3131
Path3D path = new Path3D();
3232
AddChild(path);

addons/extendable_inspector_for_cs/example/SpiralCurveCreator/SpiralCurveCreator.tscn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
[sub_resource type="Curve3D" id="1"]
66
_data = {
7-
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 3.53553, 0.05, 3.53553, 0, 0, 0, 0, 0, 0, -2.18557e-07, 0.1, 5, 0, 0, 0, 0, 0, 0, -3.53553, 0.15, 3.53553, 0, 0, 0, 0, 0, 0, -5, 0.2, -4.37114e-07, 0, 0, 0, 0, 0, 0, -3.53553, 0.25, -3.53553, 0, 0, 0, 0, 0, 0, 5.96244e-08, 0.3, -5, 0, 0, 0, 0, 0, 0, 3.53553, 0.35, -3.53553, 0, 0, 0, 0, 0, 0, 5, 0.4, -1.50996e-06, 0, 0, 0, 0, 0, 0, 3.53554, 0.45, 3.53553, 0, 0, 0, 0, 0, 0, 3.07954e-06, 0.5, 5, 0, 0, 0, 0, 0, 0, -3.53553, 0.55, 3.53554, 0, 0, 0, 0, 0, 0, -5, 0.6, -1.19249e-07, 0, 0, 0, 0, 0, 0, -3.53553, 0.65, -3.53554, 0, 0, 0, 0, 0, 0, 3.31804e-06, 0.7, -5, 0, 0, 0, 0, 0, 0, 3.53554, 0.75, -3.53553, 0, 0, 0, 0, 0, 0, 5, 0.8, 6.51683e-06, 0, 0, 0, 0, 0, 0, 3.53553, 0.85, 3.53554, 0, 0, 0, 0, 0, 0, -9.71562e-06, 0.9, 5, 0, 0, 0, 0, 0, 0, -3.53554, 0.95, 3.53553),
7+
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 3.53553, 0.1, 3.53553, 0, 0, 0, 0, 0, 0, -2.18557e-07, 0.2, 5, 0, 0, 0, 0, 0, 0, -3.53553, 0.3, 3.53553, 0, 0, 0, 0, 0, 0, -5, 0.4, -4.37114e-07, 0, 0, 0, 0, 0, 0, -3.53553, 0.5, -3.53553, 0, 0, 0, 0, 0, 0, 5.96244e-08, 0.6, -5, 0, 0, 0, 0, 0, 0, 3.53553, 0.7, -3.53553, 0, 0, 0, 0, 0, 0, 5, 0.8, -1.50996e-06, 0, 0, 0, 0, 0, 0, 3.53554, 0.9, 3.53553, 0, 0, 0, 0, 0, 0, 3.07954e-06, 1, 5, 0, 0, 0, 0, 0, 0, -3.53553, 1.1, 3.53554, 0, 0, 0, 0, 0, 0, -5, 1.2, -1.19249e-07, 0, 0, 0, 0, 0, 0, -3.53553, 1.3, -3.53554, 0, 0, 0, 0, 0, 0, 3.31804e-06, 1.4, -5, 0, 0, 0, 0, 0, 0, 3.53554, 1.5, -3.53553, 0, 0, 0, 0, 0, 0, 5, 1.6, 6.51683e-06, 0, 0, 0, 0, 0, 0, 3.53553, 1.7, 3.53554, 0, 0, 0, 0, 0, 0, -9.71562e-06, 1.8, 5, 0, 0, 0, 0, 0, 0, -3.53554, 1.9, 3.53553),
88
"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
99
}
1010
point_count = 20
1111

1212
[node name="SpiralCurveCreator" type="Node3D"]
1313
script = ExtResource("1_ypj6y")
14-
Height = 1.0
14+
Height = 2.0
1515
AmountOfPoints = 20.0
1616

1717
[node name="Path3D" type="Path3D" parent="."]

0 commit comments

Comments
 (0)