@@ -248,7 +248,7 @@ GDExtension plugin.
248248
249249 #include "gdexample.h"
250250
251- #include <godot/gdnative_interface .h>
251+ #include <gdextension_interface .h>
252252 #include <godot_cpp/core/defs.hpp>
253253 #include <godot_cpp/core/class_db.hpp>
254254 #include <godot_cpp/godot.hpp>
@@ -271,7 +271,7 @@ GDExtension plugin.
271271
272272 extern "C" {
273273 // 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) {
275275 godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
276276
277277 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:
499499 ...
500500 ClassDB::bind_method(D_METHOD("get_speed"), &GDExample::get_speed);
501501 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");
503503 }
504504
505505 void GDExample::GDExample() {
506- // initialize any variables here
507506 time_passed = 0.0;
508507 amplitude = 10.0;
509508 speed = 1.0;
@@ -532,12 +531,13 @@ showing the methods that have changed so don't remove anything we're omitting:
532531
533532Now when the project is compiled, we'll see another property called speed.
534533Changing 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.
535536
536537.. note ::
537538
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
541541 further configure how properties are displayed and set on the Godot side.
542542
543543Signals
@@ -581,9 +581,8 @@ as follows:
581581.. code-block :: C++
582582
583583 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");
587586
588587 ADD_SIGNAL(MethodInfo("position_changed", PropertyInfo(Variant::OBJECT, "node"), PropertyInfo(Variant::VECTOR2, "new_pos")));
589588 }
0 commit comments