Skip to content

Commit e8098dc

Browse files
committed
Updated addon README.md
1 parent 7ece0d6 commit e8098dc

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

addons/extendable_inspector_for_cs/README.md

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,49 @@
22

33
Makes it easier to add custom inspector controls to nodes.
44

5-
![Screenshot showing the example code in res://addons/extendable_inspector/example/ChangeRandomColor/ChangeRandomColor.gd](https://user-images.githubusercontent.com/11432672/215778616-963d902e-acc8-493c-969d-3544926a4904.png)
6-
![3d scene of a cube with a button in the inspector that says 'Change Random Color'](https://user-images.githubusercontent.com/11432672/215778698-f09496c1-a9ff-4a60-99d0-2ae5cee6ab71.png)
7-
![3d scene of same cube with a button in the inspector that says 'Change Random Color' but now the cube is of a different color](https://user-images.githubusercontent.com/11432672/215778730-78761e6d-5232-425f-acf8-1f34c5e7e614.png)
5+
![Screenshot showing the example code in res://addons/extendable_inspector_for_cs/example/ChangeRandomColor/ChangeRandomColor.cs](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/9364958/acb2336e-532b-4bf7-9700-0c3d2c444fb8)
6+
![3d scene of a cube with a button in the inspector that says 'Change To Random Color'](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/9364958/16db2d8e-3ee2-4489-98a3-158bb2b22ba2)
7+
![3d scene of a cube with a button in the inspector that says 'Change To Random Color' but now the cube is of a different color](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/9364958/5bb39e97-5d02-4f9a-a388-2e6755cd9d54)
88

99
# How to install
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).
19-
![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:
21-
![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:
23-
![image](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/11432672/2d4e62ef-7dcf-4cc5-b74c-c26bde55c70a)
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).
19+
20+
![image](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/9364958/7f0cc7e0-6a9a-4447-b73e-8fc9a0f8da6b)
21+
22+
- 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:
23+
24+
![image](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/9364958/e6ff7696-ab1c-484c-ae1e-04b75da80f47)
25+
26+
- 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:
27+
28+
![image](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/assets/9364958/d8457afd-5243-4da9-9834-b87c90f356bb)
29+
30+
31+
Here's the entire code in case you want to try it out:
32+
33+
```csharp
34+
using Godot;
35+
36+
[Tool]
37+
public partial class SayYourName : Node2D {
38+
public void ExtendInspectorBegin(ExtendableInspector inspector) {
39+
Button button = new() {
40+
Text = "Say your name"
41+
};
42+
button.Pressed += () => GD.Print(Name);
43+
inspector.AddCustomControl(button);
44+
}
45+
}
46+
```
47+
2448

2549
# How to use
2650

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

3256
These methods are:
33-
```godot
34-
void _extend_inspector_begin(inspector: ExtendableInspector)
57+
```csharp
58+
void ExtendInspectorBegin(ExtendableInspector inspector)
3559
```
3660
Allows adding controls at the beginning of the inspector.
3761

38-
```godot
39-
void _extend_inspector_end(inspector: ExtendableInspector)
62+
```csharp
63+
void ExtendInspectorEnd(ExtendableInspector inspector)
4064
```
4165

4266
Allows adding controls at the end of the inspector.
4367

44-
```godot
45-
bool _extend_inspector_category(inspector: ExtendableInspector, category: String)
68+
```csharp
69+
void ExtendInspectorCategory(inspector: ExtendableInspector, string category)
4670
```
4771

4872
Allows adding controls at the beginning of a category in the property list for object.
4973

50-
```godot
51-
void _extend_inspector_property(inspector: ExtendableInspector, object: Object, type: int, name: String, hint_type: int, hint_string: String, usage_flags: int, wide: bool)
74+
```csharp
75+
bool ExtendInspectorProperty(ExtendableInspector inspector, Variant.Type type, string name, PropertyHint hintType, string hintString, PropertyUsageFlags usageFlags, bool wide)
5276
```
5377

5478
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.
5579

5680
## Examples
5781

58-
Examples can be found in the [example folder](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/tree/godot-4/addons/extendable_inspector/example)
59-
60-
## Utils
61-
62-
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.
63-
Apart from that, there's a `utils` folder that defines some already made controls that can be added to the inspector.
82+
Examples can be found in the [example folder](https://github.com/ProFiLeR4100/ExtendableInspectorForCS/tree/godot-4/addons/extendable_inspector_for_cs/example)

0 commit comments

Comments
 (0)