mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Merge pull request #7441 from br1trs/delete-get-root
This commit is contained in:
committed by
Max Hilbrunner
parent
9956a1cff0
commit
5f794b05e1
@@ -78,7 +78,7 @@ program termination, you should send the notification yourself:
|
||||
.. tabs::
|
||||
.. code-tab:: gdscript GDScript
|
||||
|
||||
get_tree().get_root().propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)
|
||||
get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ little easier. The :ref:`Viewport <class_Viewport>`
|
||||
node has several functions to handle resizing, and the root node of the
|
||||
scene tree is always a viewport (scenes loaded are instanced as a child
|
||||
of it, and it can always be accessed by calling
|
||||
``get_tree().get_root()`` or ``get_node("/root")``).
|
||||
``get_tree().root`` or ``get_node("/root")``).
|
||||
|
||||
In any case, while changing the root Viewport params is probably the
|
||||
most flexible way to deal with the problem, it can be a lot of work,
|
||||
|
||||
@@ -17,7 +17,7 @@ scenes which one instances and adds to the tree at runtime:
|
||||
func _add_a_scene_manually():
|
||||
# This is like autoloading the scene, only
|
||||
# it happens after already loading the main scene.
|
||||
get_tree().get_root().add_child(simultaneous_scene)
|
||||
get_tree().root.add_child(simultaneous_scene)
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
@@ -32,7 +32,7 @@ scenes which one instances and adds to the tree at runtime:
|
||||
{
|
||||
// This is like autoloading the scene, only
|
||||
// it happens after already loading the main scene.
|
||||
GetTree().GetRoot().AddChild(simultaneousScene);
|
||||
GetTree().Root.AddChild(simultaneousScene);
|
||||
}
|
||||
|
||||
To complete the cycle and swap out the new scene with the old one,
|
||||
@@ -124,11 +124,11 @@ a scene's data between scene changes (adding the scene to the root node).
|
||||
.. tabs::
|
||||
.. code-tab:: gdscript GDScript
|
||||
|
||||
get_tree().get_root().add_child(scene)
|
||||
get_tree().root.add_child(scene)
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
GetTree().GetRoot().AddChild(scene);
|
||||
GetTree().Root.AddChild(scene);
|
||||
|
||||
Perhaps instead they wish to display multiple scenes at the same time using
|
||||
:ref:`SubViewportContainers <class_SubViewportContainer>`. This is optimal in
|
||||
|
||||
@@ -69,12 +69,12 @@ two different ways:
|
||||
.. tabs::
|
||||
.. code-tab:: gdscript GDScript
|
||||
|
||||
get_tree().get_root() # Access via scene main loop.
|
||||
get_tree().root # Access via scene main loop.
|
||||
get_node("/root") # Access via absolute path.
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
GetTree().GetRoot(); // Access via scene main loop.
|
||||
GetTree().Root // Access via scene main loop.
|
||||
GetNode("/root"); // Access via absolute path.
|
||||
|
||||
This node contains the main viewport. Anything that is a child of a
|
||||
|
||||
Reference in New Issue
Block a user