godotengine / godot-cpp

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

Language binding problem #1578

Open JustDooooIt opened 1 month ago

JustDooooIt commented 1 month ago

Godot version

4.3.stable

godot-cpp version

4.3.stable

System information

windows 11

Issue description

After using this method, the editor cannot detach the script and modify the visibility should be related to the implementation of GDExtensionScriptInstanceInfo3 436c41cf926de932afdd4dfcaa720e9

Steps to reproduce

create instance_info and script_instance

Minimal reproduction project

test.zip

dsnopek commented 1 month ago

Thanks!

I haven't looked too deeply, but skimming your MRP, I suspect the issue is related to not completely implementing everything required from GDExtensionScriptInstanceInfo3. In fact, I don't see where you set any of the callbacks on instance_info?

I'm a little surprised, though, that it's _instance_create() that's causing issues in the editor and not _placeholder_instance_create(), since you've hard-coded _is_tool() to false, so I wouldn't expect the editor to create a real instance, but only a placeholder.

For placeholders, in general, I'd recommend using gdextension_interface_placeholder_script_instance_create() rather than making them custom.

And you may be interested in trying out the ScriptInstanceExtension class from PR https://github.com/godotengine/godot-cpp/pull/1544. I haven't had a chance to test the latest iteration of it, but assuming it works, it should make it a little easier to make your script instances.

JustDooooIt commented 1 month ago

I don't know which interfaces are related to the functions of separate scripts and modify visibility