|
@@ -187,15 +187,28 @@ Color given as red-green-blue value (alpha will always be 1).
|
|
|
Nodes
|
|
|
-----
|
|
|
|
|
|
-Nodes can't be directly exported. Instead you need to export
|
|
|
-a node path, then use that node path with `get_node()`
|
|
|
+Since Godot 4.0, nodes can be directly exported as properties in a script
|
|
|
+without having to use NodePaths:
|
|
|
+
|
|
|
+::
|
|
|
+
|
|
|
+ # Allows any node.
|
|
|
+ @export var node: Node
|
|
|
+
|
|
|
+ # Allows any node that inherits from BaseButton.
|
|
|
+ # Custom classes declared with `class_name` can also be used.
|
|
|
+ @export var some_button: BaseButton
|
|
|
+
|
|
|
+Exporting NodePaths like in Godot 3.x is still possible, in case you need it:
|
|
|
|
|
|
::
|
|
|
|
|
|
@export var node_path: NodePath
|
|
|
var node = get_node(node_path)
|
|
|
|
|
|
-If you want to limit the types of nodes, you can use the @export_node_path annotation.
|
|
|
+If you want to limit the types of nodes for NodePaths, you can use the
|
|
|
+:ref:`@export_node_path<class_@GDScript_annotation_@export_node_path>`
|
|
|
+annotation:
|
|
|
|
|
|
::
|
|
|
|