godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.16k stars 20.21k forks source link

Members of custom nodes in a scene are not accessible when its script is running in the editor #97271

Open hexagon62 opened 2 hours ago

hexagon62 commented 2 hours ago

Tested versions

System information

Godot v4.x.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4070 Ti (NVIDIA; 32.0.15.5599) - 13th Gen Intel(R) Core(TM) i5-13600KF (20 Threads)

Issue description

I was trying to test some custom classes using a scene that runs in the editor. Things seemed to work fine until inheritance got involved. I then proceeded to create an MRP, and found that this breaks even without inheritance.

When working with a custom class in a script marked with @tool, I get errors as if the custom class's members are missing. Additionally, on one of my projects, I was able to access inherited members/methods in a derived class, but not outside of the derived class. The documentation for inherited members/methods in the derived class is also entirely absent.

None of these issues occur outside the editor. Errors are not generated while running the scene.

I am not sure if these issues are unrelated so I am lumping them into one issue.

I tried deleting the .godot folder, which did not solve the issue.

Steps to reproduce

To get the errors:

To see that this doesn't happen outside of the editor:

To see weird issues with documentation and inheritance:

Minimal reproduction project (MRP)

inheritance-bug.zip

hexagon62 commented 1 hour ago

Upon further head-scratching, I believe part of this is just that I forgot to flag these other scripts as @tool. I've done so, but I think the error reporting on this should be more clear. Also, even after putting @tool in all my scripts, it doesn't fix the documentation issue. Or... is this just how the documentation works by design?

Zireael07 commented 1 hour ago

I've done so, but I think the error reporting on this should be more clear.

This is, I believe, already requested on the proposal repository

No clue about the documentation part

hexagon62 commented 1 hour ago

Thanks for your response. I checked to see if it was proposed and didn't see anything, so here goes: maybe it makes sense to be able to toggle the @tool behavior at the node level, rather than the script level. It feels silly to add/remove @tool from the script when I only want it as a one-off thing. I'll open an issue on the proposal repository.