Browse Source

Merge pull request #1275 from skyace65/scene_tree_csharp

Add C# to Scene Tree page
Max Hilbrunner 7 years ago
parent
commit
8b94c25100
1 changed files with 17 additions and 3 deletions
  1. 17 3
      getting_started/step_by_step/scene_tree.rst

+ 17 - 3
getting_started/step_by_step/scene_tree.rst

@@ -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
 is always at the top of the scene. From a node, it can be obtained in
 two different ways:
 two different ways:
 
 
-::
+.. tabs::
+ .. code-tab:: gdscript GDScript
 
 
         get_tree().get_root() # access via scenemainloop
         get_tree().get_root() # access via scenemainloop
         get_node("/root") # access via absolute path
         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
 This node contains the main viewport, anything that is a child of a
 :ref:`Viewport <class_Viewport>`
 :ref:`Viewport <class_Viewport>`
 is drawn inside of it by default, so it makes sense that the top of all
 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>`
 :ref:`SceneTree.change_scene() <class_SceneTree_change_scene>`
 function:
 function:
 
 
-::
+.. tabs::
+ .. code-tab:: gdscript GDScript
 
 
     func _my_level_was_completed():
     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
 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
 that the game will stall until the new scene is loaded and running. At