Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use paths to reference SubViewport nodes #75740

Closed
blackears opened this issue Apr 6, 2023 · 2 comments · Fixed by #75751
Closed

Can't use paths to reference SubViewport nodes #75740

blackears opened this issue Apr 6, 2023 · 2 comments · Fixed by #75751
Milestone

Comments

@blackears
Copy link

Godot version

v4.0.2.stable.official [7a0977c]

System information

Windows 10, Compatability

Issue description

I'm trying to create a Control that will automatically render a thumbnail of a material. To do this, I've created a TextureRectangle to display the thumbnail and a SubViewport to create a simple 3D scene to render the thumbnail. Unfortunately this is causing a lot of problems with Godot being unable to resolve the path to the viewport. I read a few other bug reports I think are related, but the node that is using the SubViewport is a peer of the viewport itself.

#55818

Steps to reproduce

Try to run this project. You will get these errors when Godot tries to resolve the path.

E 0:00:01:0049 get_node: Node not found: "SubViewport" (relative to "Control").
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1364 @ get_node()
E 0:00:01:0049 setup_local_to_scene: ViewportTexture: Path to node is invalid.
<C++ Error> Condition "!vpn" is true.
<C++ Source> scene/main/viewport.cpp:76 @ setup_local_to_scene()

Minimal reproduction project

subviewportTrumbnailTest.zip

@KoBeWi
Copy link
Member

KoBeWi commented Apr 6, 2023

The problem is that the ViewportTexture initializes too early, before the node hierarchy is ready.

@dandeliondino
Copy link

Thank you for this fix. I had the same error (and a few related ones). When I removed the assignment from the inspector and instead assigned the ViewportTexture in the parent's ready function, the errors disappeared.

Also, I would love to see the is_ready() function in the PR merged. Despite having is_inside_tree(), I still end up creating my own check for ready a few times per project, and it would be great to have it built-in.

@akien-mga akien-mga added this to the 4.1 milestone May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants