Skip to content

Commit 041ff3c

Browse files
authored
Added missing C# example in tutorials -> best practices -> godot_notifications. (godotengine#7936)
* Added C# example * Fixed C# example in godot_notifications
1 parent 8a08321 commit 041ff3c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tutorials/best_practices/godot_notifications.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ implementing a Timer-timeout loop is another option.
8484
print("This block runs every 0.5 seconds")
8585
)
8686

87+
.. code-tab:: csharp
88+
89+
using Godot;
90+
91+
public partial class MyNode : Node
92+
{
93+
// Allows for recurring operations that don't trigger script logic
94+
// every frame (or even every fixed frame).
95+
public override void _Ready()
96+
{
97+
var timer = new Timer();
98+
timer.Autostart = true;
99+
timer.WaitTime = 0.5;
100+
AddChild(timer);
101+
timer.Timeout += () => GD.Print("This block runs every 0.5 seconds");
102+
}
103+
}
104+
87105
Use ``_physics_process()`` when one needs a framerate-independent delta time
88106
between frames. If code needs consistent updates over time, regardless
89107
of how fast or slow time advances, this is the right place.

0 commit comments

Comments
 (0)