2
0
Эх сурвалжийг харах

Update GDScript examples - Step By Step: Scripting

In Godot 4.0, the connect() function no longer takes an object and
a string name of a function, but rather the new Callable type. Following
the old instructions leads to errors.

Unfortunately, I don't have C# development set up on my machine, so I
have not updated the C# examples as I'm currently unable to validate that
they work as intended.
Sam Abrahams 5 жил өмнө
parent
commit
83ed812b76

+ 2 - 2
getting_started/step_by_step/scripting.rst

@@ -259,7 +259,7 @@ using :ref:`Object.connect() <class_Object_method_connect>`.
  .. code-tab:: gdscript GDScript
 
     func _ready():
-        get_node("Button").connect("pressed", self, "_on_Button_pressed")
+        get_node("Button").connect("pressed", self._on_Button_pressed)
 
  .. code-tab:: csharp
 
@@ -276,7 +276,7 @@ The final script should look like this:
     extends Panel
 
     func _ready():
-        get_node("Button").connect("pressed", self, "_on_Button_pressed")
+        get_node("Button").connect("pressed", self._on_Button_pressed)
 
     func _on_Button_pressed():
         get_node("Label").text = "HELLO!"