瀏覽代碼

Singletons tutorial has deprecated methods. (#6018)

* Singletons tutorial has deprecated methods.
Pixelatex 3 年之前
父節點
當前提交
cf1b3190f9
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      tutorials/scripting/singletons_autoload.rst

+ 6 - 6
tutorials/scripting/singletons_autoload.rst

@@ -146,7 +146,7 @@ means that the last child of root is always the loaded scene.
     var current_scene = null
 
     func _ready():
-        var root = get_tree().get_root()
+        var root = get_tree().root
         current_scene = root.get_child(root.get_child_count() - 1)
 
  .. code-tab:: csharp
@@ -160,7 +160,7 @@ means that the last child of root is always the loaded scene.
 
         public override void _Ready()
         {
-            Viewport root = GetTree().GetRoot();
+            Viewport root = GetTree().Root;
             CurrentScene = root.GetChild(root.GetChildCount() - 1);
         }
     }
@@ -195,10 +195,10 @@ current scene and replace it with the requested one.
         current_scene = s.instance()
 
         # Add it to the active scene, as child of root.
-        get_tree().get_root().add_child(current_scene)
+        get_tree().root.add_child(current_scene)
 
         # Optionally, to make it compatible with the SceneTree.change_scene() API.
-        get_tree().set_current_scene(current_scene)
+        get_tree().current_scene = current_scene
 
  .. code-tab:: csharp
 
@@ -228,10 +228,10 @@ current scene and replace it with the requested one.
         CurrentScene = nextScene.Instance();
 
         // Add it to the active scene, as child of root.
-        GetTree().GetRoot().AddChild(CurrentScene);
+        GetTree().Root.AddChild(CurrentScene);
 
         // Optionally, to make it compatible with the SceneTree.change_scene() API.
-        GetTree().SetCurrentScene(CurrentScene);
+        GetTree().CurrentScene = CurrentScene;
     }
 
 Using :ref:`Object.call_deferred() <class_Object_method_call_deferred>`,