소스 검색

Added missing C# example in tutorials -> best practices -> godot_notifications. (#7936)

* Added C# example

* Fixed C# example in godot_notifications
GamEsnitzhel 1 년 전
부모
커밋
041ff3c28d
1개의 변경된 파일18개의 추가작업 그리고 0개의 파일을 삭제
  1. 18 0
      tutorials/best_practices/godot_notifications.rst

+ 18 - 0
tutorials/best_practices/godot_notifications.rst

@@ -84,6 +84,24 @@ implementing a Timer-timeout loop is another option.
             print("This block runs every 0.5 seconds")
             print("This block runs every 0.5 seconds")
         )
         )
 
 
+ .. code-tab:: csharp
+
+    using Godot;
+
+    public partial class MyNode : Node
+    {
+        // Allows for recurring operations that don't trigger script logic
+        // every frame (or even every fixed frame).
+        public override void _Ready()
+        {
+            var timer = new Timer();
+            timer.Autostart = true;
+            timer.WaitTime = 0.5;
+            AddChild(timer);
+            timer.Timeout += () => GD.Print("This block runs every 0.5 seconds");
+        }
+    }
+
 Use ``_physics_process()`` when one needs a framerate-independent delta time
 Use ``_physics_process()`` when one needs a framerate-independent delta time
 between frames. If code needs consistent updates over time, regardless
 between frames. If code needs consistent updates over time, regardless
 of how fast or slow time advances, this is the right place.
 of how fast or slow time advances, this is the right place.