godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.71k stars 574 forks source link

GDExtensions completely broken by one of the most recent changes (presumably in the context of the rename from GDNative) #972

Closed LemiSt24 closed 1 year ago

LemiSt24 commented 1 year ago

Sorry if this belongs in the main Godot repo, I can also create an issue there if it helps.

I am actively using GDExtensions in Godot 4 Beta and compile the engine and my extensions with the most recent versions quite often. With one of the last updates, definitely since the name change from GDNative to GDExtension (https://github.com/godotengine/godot-cpp/commit/c02e644679655e842dcff543f0defef973cf946c) or one of the related commits, GDExtension or its connection to ClassDB broke.

While I can see that exporting classes somewhat works, since I get a warning that an attribute of my custom Extension has been initialized with a default value, using them in the editor or in a game has become impossible.

When I try to edit or start the provided example (under "test"), the following messages appear in the console:

SCRIPT ERROR: Parse Error: Identifier "Example" not declared in the current scope.
          at: GDScript::reload (res://main.gd:17)
SCRIPT ERROR: Parse Error: Identifier "Example" not declared in the current scope.
          at: GDScript::reload (res://main.gd:18)
SCRIPT ERROR: Parse Error: "Example" was not found in the current scope.
          at: GDScript::reload (res://main.gd:28)
SCRIPT ERROR: Parse Error: Identifier "ExampleRef" not declared in the current scope.
          at: GDScript::reload (res://main.gd:38)
ERROR: Cannot get class 'Example'.
   at: instantiate (core/object/class_db.cpp:326)
WARNING: Node Example of type Example cannot be created. A placeholder will be created instead.
     at: instantiate (scene/resources/packed_scene.cpp:201)
ERROR: Cannot get class 'ExampleMin'.
   at: instantiate (core/object/class_db.cpp:326)
WARNING: Node ExampleMin of type ExampleMin cannot be created. A placeholder will be created instead.
     at: instantiate (scene/resources/packed_scene.cpp:201)
ERROR: In Object of type 'Node': Attempt to connect nonexistent signal 'custom_signal' to callable 'Node(main.gd)::_on_Example_custom_signal'.
   at: connect (core/object/object.cpp:1256)

Problems with my custom modules are similar. It seems the extensions do not get registered in Godot's ClassDB properly.

LemiSt24 commented 1 year ago

I am embarassed to not have thought of this earlier, but the solution was dead simple: Delete the .godot folder, forcing Godot to reimport the extensions.