You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Any method that needs to be seen by a signal needs to be exported
101
+
@GodotExport()
102
+
void onSignal() {
103
+
// To call and RPC as an RPC you use the $rpc variable
104
+
$rpc.rpcMessage('message');
105
+
}
101
106
}
102
107
```
103
108
@@ -192,14 +197,47 @@ So instead, Godot Dart prefixes all virtual methods with `v`.
192
197
193
198
### Indirectly Calling Godot Functions
194
199
195
-
The Dart API uses `lowerPascalCase` instead of `snake_case` in GDScript/C++. Where possible, fields and getters/setters have been converted to properties. In general, the Dart Godot API strives to be as idiomatic as is reasonably possible.
200
+
The Dart API uses `lowerPascalCase` instead of `snake_case` in GDScript/C++. In general, the Dart Godot API
201
+
strives to be as idiomatic as is reasonably possible.
196
202
197
-
However, Godot still thinks of these methods as being named in `snake_case`, so if you are calling them by their name (for example)
203
+
However, Godot still thinks of these methods as being named in `snake_case`, so if you are calling them by their name
198
204
when using `call`, `callDeferred`, `connect`, or `callGroup`, you need to use `snake_case` for the method name.
199
205
200
206
Basically, if you defined the method, use `lowerPascalCase`. If Godot defined the method, use `snake_case`. And if Godot defined
201
207
the method and its virtual, use `_snake_case` instead of `vPascalCase` currently used in Dart.
202
208
209
+
### Lack of Properties
210
+
211
+
While Dart supports properties, I have specifically not converted Godot fields to Dart properties, and instead leave them
212
+
with `getX` and `setX` methods.
213
+
214
+
This is to avoid [this issue](https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_basics.html#common-pitfalls),
215
+
which is common with this type of embedding. For example:
216
+
217
+
```dart
218
+
// The `x` property on the vector is set, but the `position` is not changed because the position
219
+
// setter is never called, therefore the change is never broadcast back to Godot
220
+
position.x += 5
221
+
```
222
+
223
+
The common workaround for this is to do this:
224
+
225
+
```dart
226
+
final pos = position;
227
+
pos.x = 5;
228
+
position = pos;
229
+
```
230
+
231
+
But in my opinion, this defeats the purpose of wrapping properties. Properties should mimic public member variables, and, when they
232
+
can't, use methods instead.
233
+
234
+
# Performance
235
+
236
+
I have not measured the performance of this extension, partially because I know there is a lot of space for improvement in the
237
+
embedding library itself, as well as in how the built in types are currently built.
238
+
239
+
Once I've performed an optimization pass on the library, I'll look into measuring its performance.
240
+
203
241
# More Info
204
242
205
243
This utilizes my custom built Dart shared library for embedding Dart, the source
0 commit comments