godotengine / godotengine/godot

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

Open
#97,271 3 comments 0 reactions 0 assignees View on GitHub
discussion documentation topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in 4.3.stable, 4.2.stable, 4.1.stable

### 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:

- Create a custom class derived from a built-in node.
- Create a new scene.
- Attach a script marked with `@tool` to the scene.
- Add an instance of your custom node to the scene.
- Make the script modify members or call methods from this custom node, while still in the editor.

To see that this doesn't happen outside of the editor:
- Simply make your script modify the custom node outside the editor
- Run the scene.

To see weird issues with documentation and inheritance:
- Create a class that is derived from your custom node.
- Do not redefine anything inherited from the custom node.
- Open the custom documentation for your classes.
- Notice how things defined in the base class are absent from the derived class's documentation.
- In the editor, try accessing inherited things from the derived class, but not from outside the derived class.
- Now try doing so from outside the class. You will get an error.

### Minimal reproduction project (MRP)

[inheritance-bug.zip](https://github.com/user-attachments/files/17083386/inheritance-bug.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.