@@ -248,7 +248,7 @@ GDExtension plugin.
248
248
249
249
#include "gdexample.h"
250
250
251
- #include <godot/gdnative_interface .h>
251
+ #include <gdextension_interface .h>
252
252
#include <godot_cpp/core/defs.hpp>
253
253
#include <godot_cpp/core/class_db.hpp>
254
254
#include <godot_cpp/godot.hpp>
@@ -271,7 +271,7 @@ GDExtension plugin.
271
271
272
272
extern "C" {
273
273
// Initialization.
274
- GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) {
274
+ GDExtensionBool GDE_EXPORT example_library_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
275
275
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
276
276
277
277
init_obj.register_initializer(initialize_example_module);
@@ -499,11 +499,10 @@ showing the methods that have changed so don't remove anything we're omitting:
499
499
...
500
500
ClassDB::bind_method(D_METHOD("get_speed"), &GDExample::get_speed);
501
501
ClassDB::bind_method(D_METHOD("set_speed", "p_speed"), &GDExample::set_speed);
502
- ClassDB::add_property("GDExample", PropertyInfo(Variant::FLOAT, "speed"), "set_speed", "get_speed");
502
+ ClassDB::add_property("GDExample", PropertyInfo(Variant::FLOAT, "speed", PROPERTY_HINT_RANGE, "0,20,0.01" ), "set_speed", "get_speed");
503
503
}
504
504
505
505
void GDExample::GDExample() {
506
- // initialize any variables here
507
506
time_passed = 0.0;
508
507
amplitude = 10.0;
509
508
speed = 1.0;
@@ -532,12 +531,13 @@ showing the methods that have changed so don't remove anything we're omitting:
532
531
533
532
Now when the project is compiled, we'll see another property called speed.
534
533
Changing its value will make the animation go faster or slower.
534
+ Furthermore, we added a property range which describes in which range the value can be.
535
+ The first two arguments are the minimum and maximum value and the third is the step size.
535
536
536
537
.. note ::
537
538
538
- For simplicity, we've left out the optional parameters in the
539
- add_property() method call. These parameters are
540
- ``hint ``, ``hint_string ``, ``usage `` and ``class_name ``. These can be used to
539
+ For simplicity, we've only used the hint_range of the property method.
540
+ There are a lot more options to choose from. These can be used to
541
541
further configure how properties are displayed and set on the Godot side.
542
542
543
543
Signals
@@ -581,9 +581,8 @@ as follows:
581
581
.. code-block :: C++
582
582
583
583
void GDExample::_bind_methods() {
584
- ClassDB::add_property("GDExample", PropertyInfo(Variant::FLOAT, "amplitude"), "set_amplitude", "get_amplitude");
585
- ClassDB::add_property("GDExample", PropertyInfo(Variant::FLOAT, "speed"), "set_speed", "get_speed");
586
-
584
+ ...
585
+ ClassDB::add_property("GDExample", PropertyInfo(Variant::FLOAT, "speed", PROPERTY_HINT_RANGE, "0,20,0.01"), "set_speed", "get_speed");
587
586
588
587
ADD_SIGNAL(MethodInfo("position_changed", PropertyInfo(Variant::OBJECT, "node"), PropertyInfo(Variant::VECTOR2, "new_pos")));
589
588
}
0 commit comments