|
@@ -75,11 +75,17 @@ The root :ref:`Viewport <class_Viewport>`
|
|
|
is always at the top of the scene. From a node, it can be obtained in
|
|
|
two different ways:
|
|
|
|
|
|
-::
|
|
|
+.. tabs::
|
|
|
+ .. code-tab:: gdscript GDScript
|
|
|
|
|
|
get_tree().get_root() # access via scenemainloop
|
|
|
get_node("/root") # access via absolute path
|
|
|
|
|
|
+ .. code-tab:: csharp
|
|
|
+
|
|
|
+ GetTree().GetRoot(); // access via scenemainloop
|
|
|
+ GetNode("/root"); // access via absolute path
|
|
|
+
|
|
|
This node contains the main viewport, anything that is a child of a
|
|
|
:ref:`Viewport <class_Viewport>`
|
|
|
is drawn inside of it by default, so it makes sense that the top of all
|
|
@@ -140,10 +146,18 @@ another one. The simple way to do this is to use the
|
|
|
:ref:`SceneTree.change_scene() <class_SceneTree_change_scene>`
|
|
|
function:
|
|
|
|
|
|
-::
|
|
|
+.. tabs::
|
|
|
+ .. code-tab:: gdscript GDScript
|
|
|
|
|
|
func _my_level_was_completed():
|
|
|
- get_tree().change_scene("res://levels/level2.tscn")
|
|
|
+ get_tree().change_scene("res://levels/level2.tscn")
|
|
|
+
|
|
|
+ .. code-tab:: csharp
|
|
|
+
|
|
|
+ public void _MyLevelWasCompleted()
|
|
|
+ {
|
|
|
+ GetTree().ChangeScene("res://levels/level2.tscn");
|
|
|
+ }
|
|
|
|
|
|
This is a quick and useful way to switch scenes, but has the drawback
|
|
|
that the game will stall until the new scene is loaded and running. At
|