File: get_node_without_onready.gd

package info (click to toggle)
godot 4.4.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 229,428 kB
  • sloc: cpp: 1,657,504; ansic: 186,969; xml: 153,923; cs: 36,104; java: 29,122; python: 15,230; javascript: 6,211; yacc: 4,115; pascal: 818; objc: 459; sh: 459; makefile: 109
file content (30 lines) | stat: -rw-r--r-- 815 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
extends Node

var add_node = do_add_nodes() # Hack to have nodes on init and not fail at runtime.

var shorthand = $Node
var with_self = self.get_node(^"Node")
var without_self = get_node(^"Node")
var with_cast = get_node(^"Node") as Node
var shorthand_with_cast = $Node as Node

var shorthand_unique = %UniqueNode
var shorthand_in_dollar_unique = $"%UniqueNode"
var without_self_unique = get_node(^"%UniqueNode")
var shorthand_with_cast_unique = %UniqueNode as Node

func test():
	print("warn")

func do_add_nodes():
	var node = Node.new()
	node.name = "Node"
	@warning_ignore("unsafe_call_argument")
	add_child(node)

	var unique_node = Node.new()
	unique_node.name = "UniqueNode"
	@warning_ignore("unsafe_call_argument")
	add_child(unique_node)
	unique_node.owner = self
	unique_node.unique_name_in_owner = true