From 17530e09f2da3aa4d2470cf80283e84dc531c870 Mon Sep 17 00:00:00 2001 From: somebody_master Date: Thu, 16 Feb 2023 21:57:27 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1adir=20funcion=20de=20prueba=20y=20enlaz?= =?UTF-8?q?arla=20para=20su=20llamada=20desde=20gdscript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: somebody_master --- Test.gd | 10 ++++++++++ TestGDExtension.tscn | 8 ++++++++ gdextension/src/test.cpp | 11 +++++++++++ gdextension/src/test.h | 8 +++++--- project.godot | 1 + 5 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 Test.gd create mode 100644 TestGDExtension.tscn diff --git a/Test.gd b/Test.gd new file mode 100644 index 0000000..0cdd158 --- /dev/null +++ b/Test.gd @@ -0,0 +1,10 @@ +extends Test + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + start_test() + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/TestGDExtension.tscn b/TestGDExtension.tscn new file mode 100644 index 0000000..b769393 --- /dev/null +++ b/TestGDExtension.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://ccd73px2acqli"] + +[ext_resource type="Script" path="res://Test.gd" id="1_3ucc5"] + +[node name="Node3D" type="Node3D"] + +[node name="Test" type="Test" parent="."] +script = ExtResource("1_3ucc5") diff --git a/gdextension/src/test.cpp b/gdextension/src/test.cpp index 33296cc..d1bf2c4 100644 --- a/gdextension/src/test.cpp +++ b/gdextension/src/test.cpp @@ -1 +1,12 @@ #include "test.h" + +#include + +void Test::start_test() { + UtilityFunctions::print("Hello world form GDExtension"); +} + +void Test::_bind_methods() { +ClassDB: + ClassDB::bind_method(D_METHOD("start_test"), &Test::start_test); +} diff --git a/gdextension/src/test.h b/gdextension/src/test.h index 954eee3..692d4b1 100644 --- a/gdextension/src/test.h +++ b/gdextension/src/test.h @@ -8,8 +8,10 @@ using namespace godot; class Test : public Node3D { GDCLASS(Test, Node3D); -protected: - static void _bind_methods() {} -}; +public: + void start_test(); +protected: + static void _bind_methods(); +}; #endif diff --git a/project.godot b/project.godot index 75e6a64..1e93961 100644 --- a/project.godot +++ b/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="TestGDExtension" +run/main_scene="res://TestGDExtension.tscn" config/features=PackedStringArray("4.0", "Forward Plus") config/icon="res://icon.svg"