Skip to content

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

Closed
@bend-n

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions