summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-11-24 11:56:11 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-11-24 11:56:11 +0100
commit8d43168fd73fc19563adc947bb48e488db95c7f6 (patch)
tree1de1274a2b1380f6e8009d3b1a5018689ed9659a
parent066e7d483a8f699fd94e7133ac23978cd460a72d (diff)
parentab01dc5a480c52be8a61c1cc802fffa83eb590d9 (diff)
downloadredot-engine-8d43168fd73fc19563adc947bb48e488db95c7f6.tar.gz
Merge pull request #85279 from RandomShaper/enhance_change_scene_docs
Enhance `SceneTree.change_scene*()` methods' docs
-rw-r--r--doc/classes/SceneTree.xml7
1 files changed, 5 insertions, 2 deletions
diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml
index da23eadfd1..08cfe3c6ca 100644
--- a/doc/classes/SceneTree.xml
+++ b/doc/classes/SceneTree.xml
@@ -42,7 +42,7 @@
<description>
Changes the running scene to the one at the given [param path], after loading it into a [PackedScene] and creating a new instance.
Returns [constant OK] on success, [constant ERR_CANT_OPEN] if the [param path] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if that scene cannot be instantiated.
- [b]Note:[/b] The new scene node is added to the tree at the end of the frame. This ensures that both scenes aren't running at the same time, while still freeing the previous scene in a safe way similar to [method Node.queue_free]. As such, you won't be able to access the loaded scene immediately after the [method change_scene_to_file] call.
+ [b]Note:[/b] See [method change_scene_to_packed] for details on the order of operations.
</description>
</method>
<method name="change_scene_to_packed">
@@ -51,7 +51,10 @@
<description>
Changes the running scene to a new instance of the given [PackedScene] (which must be valid).
Returns [constant OK] on success, [constant ERR_CANT_CREATE] if the scene cannot be instantiated, or [constant ERR_INVALID_PARAMETER] if the scene is invalid.
- [b]Note:[/b] The new scene node is added to the tree at the end of the frame. You won't be able to access it immediately after the [method change_scene_to_packed] call.
+ [b]Note:[/b] Operations happen in the following order when [method change_scene_to_packed] is called:
+ 1. The current scene node is immediately removed from the tree. From that point, [method Node.get_tree] called on the current (outgoing) scene will return [code]null[/code]. [member current_scene] will be [code]null[/code], too, because the new scene is not available yet.
+ 2. At the end of the frame, the formerly current scene, already removed from the tree, will be deleted (freed from memory) and then the new scene will be instantiated and added to the tree. [method Node.get_tree] and [member current_scene] will be back to working as usual.
+ This ensures that both scenes aren't running at the same time, while still freeing the previous scene in a safe way similar to [method Node.queue_free].
</description>
</method>
<method name="create_timer">