2018-01-12 08:03:11 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2022-02-14 13:18:53 +00:00
<class name= "SceneTree" inherits= "MainLoop" version= "4.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
2019-06-26 13:57:13 +00:00
Manages the game loop via a hierarchy of nodes.
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2019-06-26 13:57:13 +00:00
As one of the most important classes, the [SceneTree] manages the hierarchy of nodes in a scene as well as scenes themselves. Nodes can be added, retrieved and removed. The whole scene tree (and thus the current scene) can be paused. Scenes can be loaded, switched and reloaded.
2021-03-18 11:04:28 +00:00
You can also use the [SceneTree] to organize your nodes into groups: every node can be assigned as many groups as you want to create, e.g. an "enemy" group. You can then iterate these groups or even call methods and set properties on all the group's members at once.
2019-06-26 13:57:13 +00:00
[SceneTree] is the default [MainLoop] implementation used by scenes, and is thus in charge of the game loop.
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
2021-11-15 09:43:07 +00:00
<link title= "SceneTree" > $DOCS_URL/tutorials/scripting/scene_tree.html</link>
<link title= "Multiple resolutions" > $DOCS_URL/tutorials/rendering/multiple_resolutions.html</link>
2017-09-12 20:42:36 +00:00
</tutorials>
<methods >
<method name= "call_group" qualifiers= "vararg" >
2022-02-22 11:15:43 +00:00
<return type= "void" />
2021-07-30 13:28:05 +00:00
<argument index= "0" name= "group" type= "StringName" />
<argument index= "1" name= "method" type= "StringName" />
2017-09-12 20:42:36 +00:00
<description >
2021-08-12 21:40:13 +00:00
Calls [code]method[/code] on each member of the given group. You can pass arguments to [code]method[/code] by specifying them at the end of the method call.
2021-10-07 16:54:09 +00:00
[b]Note:[/b] Due to design limitations, [method call_group] will fail silently if one of the arguments is [code]null[/code].
2021-08-12 21:40:13 +00:00
[b]Note:[/b] [method call_group] will call methods immediately on all members at once, which can cause stuttering if an expensive method is called on lots of members. To wait for one frame after [method call_group] was called, use [method call_group_flags] with the [constant GROUP_CALL_DEFERRED] flag.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "call_group_flags" qualifiers= "vararg" >
2022-02-22 11:15:43 +00:00
<return type= "void" />
2021-07-30 13:28:05 +00:00
<argument index= "0" name= "flags" type= "int" />
<argument index= "1" name= "group" type= "StringName" />
<argument index= "2" name= "method" type= "StringName" />
2017-09-12 20:42:36 +00:00
<description >
2021-04-29 19:22:32 +00:00
Calls [code]method[/code] on each member of the given group, respecting the given [enum GroupCallFlags]. You can pass arguments to [code]method[/code] by specifying them at the end of the method call.
2021-03-23 14:16:36 +00:00
[codeblock]
2021-08-12 21:40:13 +00:00
# Call the method in a deferred manner and in reverse order.
get_tree().call_group_flags(SceneTree.GROUP_CALL_DEFERRED | SceneTree.GROUP_CALL_REVERSE)
2021-03-23 14:16:36 +00:00
[/codeblock]
2021-08-12 21:40:13 +00:00
[b]Note:[/b] Due to design limitations, [method call_group_flags] will fail silently if one of the arguments is [code]null[/code].
[b]Note:[/b] Group call flags are used to control the method calling behavior. By default, methods will be called immediately in a way similar to [method call_group]. However, if the [constant GROUP_CALL_DEFERRED] flag is present in the [code]flags[/code] argument, methods will be called with a one-frame delay in a way similar to [method Object.set_deferred].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "change_scene" >
2021-07-30 13:28:05 +00:00
<return type= "int" enum= "Error" />
<argument index= "0" name= "path" type= "String" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-26 13:57:13 +00:00
Changes the running scene to the one at the given [code]path[/code], after loading it into a [PackedScene] and creating a new instance.
2019-06-27 11:24:03 +00:00
Returns [constant OK] on success, [constant ERR_CANT_OPEN] if the [code]path[/code] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if that scene cannot be instantiated.
2020-12-27 20:51:54 +00:00
[b]Note:[/b] The scene change is deferred, which means that the new scene node is added on the next idle frame. You won't be able to access it immediately after the [method change_scene] call.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "change_scene_to" >
2021-07-30 13:28:05 +00:00
<return type= "int" enum= "Error" />
<argument index= "0" name= "packed_scene" type= "PackedScene" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-26 13:57:13 +00:00
Changes the running scene to a new instance of the given [PackedScene].
2019-06-27 11:24:03 +00:00
Returns [constant OK] on success or [constant ERR_CANT_CREATE] if the scene cannot be instantiated.
2020-12-27 20:51:54 +00:00
[b]Note:[/b] The scene change is deferred, which means that the new scene node is added on the next idle frame. You won't be able to access it immediately after the [method change_scene_to] call.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "create_timer" >
2021-07-30 13:28:05 +00:00
<return type= "SceneTreeTimer" />
<argument index= "0" name= "time_sec" type= "float" />
<argument index= "1" name= "process_always" type= "bool" default= "true" />
2017-09-12 20:42:36 +00:00
<description >
2021-02-19 12:57:41 +00:00
Returns a [SceneTreeTimer] which will [signal SceneTreeTimer.timeout] after the given time in seconds elapsed in this [SceneTree]. If [code]process_always[/code] is set to [code]false[/code], pausing the [SceneTree] will also pause the timer.
2019-02-24 02:56:10 +00:00
Commonly used to create a one-shot delay timer as in the following example:
2020-11-27 23:33:15 +00:00
[codeblocks]
[gdscript]
2019-02-24 02:56:10 +00:00
func some_function():
2019-09-28 00:21:58 +00:00
print("start")
2021-10-22 18:28:37 +00:00
await get_tree().create_timer(1.0).timeout
2019-09-28 00:21:58 +00:00
print("end")
2020-11-27 23:33:15 +00:00
[/gdscript]
[csharp]
public async void SomeFunction()
{
GD.Print("start");
await ToSignal(GetTree().CreateTimer(1.0f), "timeout");
GD.Print("end");
}
[/csharp]
[/codeblocks]
2021-01-23 17:53:22 +00:00
The timer will be automatically freed after its time elapses.
2017-09-12 20:42:36 +00:00
</description>
</method>
2020-09-05 01:05:30 +00:00
<method name= "create_tween" >
2021-07-30 13:28:05 +00:00
<return type= "Tween" />
2020-09-05 01:05:30 +00:00
<description >
Creates and returns a new [Tween].
</description>
</method>
2021-03-10 09:54:21 +00:00
<method name= "get_first_node_in_group" >
2021-07-30 13:28:05 +00:00
<return type= "Node" />
<argument index= "0" name= "group" type= "StringName" />
2021-03-10 09:54:21 +00:00
<description >
2022-04-29 14:14:48 +00:00
Returns the first node in the specified group, or [code]null[/code] if the group is empty or does not exist.
2021-03-10 09:54:21 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_frame" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-26 13:57:13 +00:00
Returns the current frame number, i.e. the total frame count since the application started.
2017-09-12 20:42:36 +00:00
</description>
</method>
2022-02-05 00:43:47 +00:00
<method name= "get_multiplayer" qualifiers= "const" >
<return type= "MultiplayerAPI" />
<argument index= "0" name= "for_path" type= "NodePath" default= "NodePath("")" />
<description >
Return the [MultiplayerAPI] configured for the given path, or the default one if [code]for_path[/code] is empty.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_node_count" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-26 13:57:13 +00:00
Returns the number of nodes in this [SceneTree].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_nodes_in_group" >
2021-07-30 13:28:05 +00:00
<return type= "Array" />
<argument index= "0" name= "group" type= "StringName" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-26 13:57:13 +00:00
Returns a list of all nodes assigned to the given group.
2017-09-12 20:42:36 +00:00
</description>
</method>
2020-09-05 01:05:30 +00:00
<method name= "get_processed_tweens" >
2021-07-30 13:28:05 +00:00
<return type= "Array" />
2020-09-05 01:05:30 +00:00
<description >
Fix various typos with codespell
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-07 15:17:32 +00:00
Returns an array of currently existing [Tween]s in the [SceneTree] (both running and paused).
2020-09-05 01:05:30 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "has_group" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "name" type= "StringName" />
2017-09-12 20:42:36 +00:00
<description >
2018-04-08 20:38:45 +00:00
Returns [code]true[/code] if the given group exists.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "notify_group" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "group" type= "StringName" />
<argument index= "1" name= "notification" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2018-04-08 20:38:45 +00:00
Sends the given notification to all members of the [code]group[/code].
2021-08-12 21:40:13 +00:00
[b]Note:[/b] [method notify_group] will immediately notify all members at once, which can cause stuttering if an expensive method is called as a result of sending the notification lots of members. To wait for one frame, use [method notify_group_flags] with the [constant GROUP_CALL_DEFERRED] flag.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "notify_group_flags" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "call_flags" type= "int" />
<argument index= "1" name= "group" type= "StringName" />
<argument index= "2" name= "notification" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-27 04:22:34 +00:00
Sends the given notification to all members of the [code]group[/code], respecting the given [enum GroupCallFlags].
2021-08-12 21:40:13 +00:00
[b]Note:[/b] Group call flags are used to control the notification sending behavior. By default, notifications will be sent immediately in a way similar to [method notify_group]. However, if the [constant GROUP_CALL_DEFERRED] flag is present in the [code]flags[/code] argument, notifications will be sent with a one-frame delay in a way similar to using [code]Object.call_deferred("notification", ...)[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "queue_delete" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "obj" type= "Object" />
2017-09-12 20:42:36 +00:00
<description >
2018-04-08 20:38:45 +00:00
Queues the given object for deletion, delaying the call to [method Object.free] to after the current frame.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "quit" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "exit_code" type= "int" default= "0" />
2017-09-12 20:42:36 +00:00
<description >
2020-06-04 20:03:45 +00:00
Quits the application at the end of the current iteration. Argument [code]exit_code[/code] can optionally be given (defaulting to 0) to customize the exit status code.
By convention, an exit code of [code]0[/code] indicates success whereas a non-zero exit code indicates an error.
For portability reasons, the exit code should be set between 0 and 125 (inclusive).
2021-06-05 23:05:14 +00:00
[b]Note:[/b] On iOS this method doesn't work. Instead, as recommended by the iOS Human Interface Guidelines, the user is expected to close apps via the Home button.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "reload_current_scene" >
2021-07-30 13:28:05 +00:00
<return type= "int" enum= "Error" />
2017-09-12 20:42:36 +00:00
<description >
2018-04-08 20:38:45 +00:00
Reloads the currently active scene.
2019-11-12 15:42:32 +00:00
Returns [constant OK] on success, [constant ERR_UNCONFIGURED] if no [member current_scene] was defined yet, [constant ERR_CANT_OPEN] if [member current_scene] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if the scene cannot be instantiated.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_group" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "group" type= "StringName" />
<argument index= "1" name= "property" type= "String" />
<argument index= "2" name= "value" type= "Variant" />
2017-09-12 20:42:36 +00:00
<description >
2018-04-08 20:38:45 +00:00
Sets the given [code]property[/code] to [code]value[/code] on all members of the given group.
2021-08-12 21:40:13 +00:00
[b]Note:[/b] [method set_group] will set the property immediately on all members at once, which can cause stuttering if a property with an expensive setter is set on lots of members. To wait for one frame, use [method set_group_flags] with the [constant GROUP_CALL_DEFERRED] flag.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_group_flags" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "call_flags" type= "int" />
<argument index= "1" name= "group" type= "StringName" />
<argument index= "2" name= "property" type= "String" />
<argument index= "3" name= "value" type= "Variant" />
2017-09-12 20:42:36 +00:00
<description >
2018-05-27 04:22:34 +00:00
Sets the given [code]property[/code] to [code]value[/code] on all members of the given group, respecting the given [enum GroupCallFlags].
2021-08-12 21:40:13 +00:00
[b]Note:[/b] Group call flags are used to control the property setting behavior. By default, properties will be set immediately in a way similar to [method set_group]. However, if the [constant GROUP_CALL_DEFERRED] flag is present in the [code]flags[/code] argument, properties will be set with a one-frame delay in a way similar to [method Object.call_deferred].
2017-09-12 20:42:36 +00:00
</description>
</method>
2022-02-05 00:43:47 +00:00
<method name= "set_multiplayer" >
<return type= "void" />
<argument index= "0" name= "multiplayer" type= "MultiplayerAPI" />
<argument index= "1" name= "root_path" type= "NodePath" default= "NodePath("")" />
<description >
Sets a custom [MultiplayerAPI] with the given [code]root_path[/code] (controlling also the relative subpaths), or override the default one if [code]root_path[/code] is empty.
</description>
</method>
2017-09-12 20:42:36 +00:00
</methods>
2018-01-11 22:38:35 +00:00
<members >
2022-05-14 10:18:26 +00:00
<member name= "auto_accept_quit" type= "bool" setter= "set_auto_accept_quit" getter= "is_auto_accept_quit" default= "true" >
If [code]true[/code], the application automatically accepts quitting.
For mobile platforms, see [member quit_on_go_back].
</member>
2019-06-29 19:22:15 +00:00
<member name= "current_scene" type= "Node" setter= "set_current_scene" getter= "get_current_scene" >
2018-04-08 20:38:45 +00:00
The current scene.
2018-01-11 22:38:35 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "debug_collisions_hint" type= "bool" setter= "set_debug_collisions_hint" getter= "is_debugging_collisions_hint" default= "false" >
2019-06-26 13:57:13 +00:00
If [code]true[/code], collision shapes will be visible when running the game from the editor for debugging purposes.
2018-01-11 22:38:35 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "debug_navigation_hint" type= "bool" setter= "set_debug_navigation_hint" getter= "is_debugging_navigation_hint" default= "false" >
2019-06-26 13:57:13 +00:00
If [code]true[/code], navigation polygons will be visible when running the game from the editor for debugging purposes.
2018-01-11 22:38:35 +00:00
</member>
2022-06-15 21:24:06 +00:00
<member name= "debug_paths_hint" type= "bool" setter= "set_debug_paths_hint" getter= "is_debugging_paths_hint" default= "false" >
If [code]true[/code], curves from [Path2D] and [Path3D] nodes will be visible when running the game from the editor for debugging purposes.
</member>
2019-06-29 19:22:15 +00:00
<member name= "edited_scene_root" type= "Node" setter= "set_edited_scene_root" getter= "get_edited_scene_root" >
2018-04-08 20:38:45 +00:00
The root of the edited scene.
2018-01-11 22:38:35 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "multiplayer_poll" type= "bool" setter= "set_multiplayer_poll_enabled" getter= "is_multiplayer_poll_enabled" default= "true" >
2021-01-04 13:33:44 +00:00
If [code]true[/code] (default value), enables automatic polling of the [MultiplayerAPI] for this SceneTree during [signal process_frame].
2021-09-08 12:37:22 +00:00
If [code]false[/code], you need to manually call [method MultiplayerAPI.poll] to process network packets and deliver RPCs. This allows running RPCs in a different loop (e.g. physics, thread, specific time step) and for manual [Mutex] protection when accessing the [MultiplayerAPI] from threads.
2018-06-02 12:32:30 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "paused" type= "bool" setter= "set_pause" getter= "is_paused" default= "false" >
2019-06-26 13:57:13 +00:00
If [code]true[/code], the [SceneTree] is paused. Doing so will have the following behavior:
2021-07-06 15:17:14 +00:00
- 2D and 3D physics will be stopped. This includes signals and collision detection.
2019-06-26 13:57:13 +00:00
- [method Node._process], [method Node._physics_process] and [method Node._input] will not be called anymore in nodes.
2018-01-11 22:38:35 +00:00
</member>
2022-05-14 10:18:26 +00:00
<member name= "quit_on_go_back" type= "bool" setter= "set_quit_on_go_back" getter= "is_quit_on_go_back" default= "true" >
If [code]true[/code], the application quits automatically on going back (e.g. on Android).
To handle 'Go Back' button when this option is disabled, use [constant DisplayServer.WINDOW_EVENT_GO_BACK_REQUEST].
</member>
2020-03-31 09:56:58 +00:00
<member name= "root" type= "Window" setter= "" getter= "get_root" >
The [SceneTree]'s root [Window].
2018-01-11 22:38:35 +00:00
</member>
</members>
2017-09-12 20:42:36 +00:00
<signals >
2017-10-21 10:02:08 +00:00
<signal name= "node_added" >
2021-07-30 13:28:05 +00:00
<argument index= "0" name= "node" type= "Node" />
2017-10-21 10:02:08 +00:00
<description >
2019-06-26 13:57:13 +00:00
Emitted whenever a node is added to the [SceneTree].
2017-10-21 10:02:08 +00:00
</description>
</signal>
2017-09-12 20:42:36 +00:00
<signal name= "node_configuration_warning_changed" >
2021-07-30 13:28:05 +00:00
<argument index= "0" name= "node" type= "Node" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-21 23:04:47 +00:00
Emitted when a node's configuration changed. Only emitted in [code]tool[/code] mode.
2017-09-12 20:42:36 +00:00
</description>
</signal>
<signal name= "node_removed" >
2021-07-30 13:28:05 +00:00
<argument index= "0" name= "node" type= "Node" />
2017-09-12 20:42:36 +00:00
<description >
2019-06-26 13:57:13 +00:00
Emitted whenever a node is removed from the [SceneTree].
2017-09-12 20:42:36 +00:00
</description>
</signal>
2019-05-28 16:08:13 +00:00
<signal name= "node_renamed" >
2021-07-30 13:28:05 +00:00
<argument index= "0" name= "node" type= "Node" />
2019-05-28 16:08:13 +00:00
<description >
2019-06-26 13:57:13 +00:00
Emitted whenever a node is renamed.
2019-05-28 16:08:13 +00:00
</description>
</signal>
2017-10-11 21:54:43 +00:00
<signal name= "physics_frame" >
<description >
2019-06-26 13:57:13 +00:00
Emitted immediately before [method Node._physics_process] is called on every node in the [SceneTree].
2021-01-04 13:33:44 +00:00
</description>
</signal>
<signal name= "process_frame" >
<description >
Emitted immediately before [method Node._process] is called on every node in the [SceneTree].
2017-10-11 21:54:43 +00:00
</description>
</signal>
2017-09-12 20:42:36 +00:00
<signal name= "tree_changed" >
<description >
2019-06-26 13:57:13 +00:00
Emitted whenever the [SceneTree] hierarchy changed (children being moved or renamed, etc.).
2017-09-12 20:42:36 +00:00
</description>
</signal>
2021-02-19 12:35:31 +00:00
<signal name= "tree_process_mode_changed" >
<description >
2021-02-19 12:57:41 +00:00
This signal is only emitted in the editor, it allows the editor to update the visibility of disabled nodes. Emitted whenever any node's [member Node.process_mode] is changed.
2021-02-19 12:35:31 +00:00
</description>
</signal>
2017-09-12 20:42:36 +00:00
</signals>
<constants >
2018-01-03 12:45:03 +00:00
<constant name= "GROUP_CALL_DEFAULT" value= "0" enum= "GroupCallFlags" >
2018-04-16 14:44:46 +00:00
Call a group with no flags (default).
2017-09-12 20:42:36 +00:00
</constant>
2018-01-03 12:45:03 +00:00
<constant name= "GROUP_CALL_REVERSE" value= "1" enum= "GroupCallFlags" >
2018-04-16 14:44:46 +00:00
Call a group in reverse scene order.
2017-09-12 20:42:36 +00:00
</constant>
2021-08-12 21:40:13 +00:00
<constant name= "GROUP_CALL_DEFERRED" value= "2" enum= "GroupCallFlags" >
Call a group with a one-frame delay (idle frame, not physics).
2017-09-12 20:42:36 +00:00
</constant>
2018-01-03 12:45:03 +00:00
<constant name= "GROUP_CALL_UNIQUE" value= "4" enum= "GroupCallFlags" >
2018-04-16 14:44:46 +00:00
Call a group only once even if the call is executed many times.
2017-09-12 20:42:36 +00:00
</constant>
</constants>
</class>