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

Accessing scene unique nodes in a static function from a different node causes error instead of returning null #75645

Closed
bend-n opened this issue Apr 4, 2023 · 1 comment · Fixed by #78552

Comments

@bend-n
Copy link
Contributor

bend-n commented Apr 4, 2023

Godot version

ef02571

System information

ArchLinux x11

Issue description

Accessing a scene unique node like this:

class_name Class extends Node
static func get_label() -> Label:
	return %label

and then accessing that class later:

func _ready() -> void:
	Main.get_label().text = "hello world"

causes a strange error when in the editor, and a normal error when run directly.
image

ERROR: Node not found: "%label" (relative to "/root/main").
   at: get_node (scene/main/node.cpp:1364)

Instead of returning null.
As opposed to when using get_node:


SCRIPT ERROR: Cannot call method 'get_node' on a null value.
          at: get_label (res://main.gd:5)
SCRIPT ERROR: Invalid set index 'text' (on base: 'Nil') with value of type 'String'.
          at: _ready (res://control.gd:4)

Steps to reproduce

Run mrp or follow outlined steps

Minimal reproduction project

bug.zip

@KoBeWi
Copy link
Member

KoBeWi commented Apr 4, 2023

The error should be something like this:
image
Seems like % and $ are not handled properly in static methods.

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.

3 participants