mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-03 05:48:42 +03:00
Singletons tutorial has deprecated methods. (#6018)
* Singletons tutorial has deprecated methods.
This commit is contained in:
@@ -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>`,
|
||||
|
||||
Reference in New Issue
Block a user