Created
November 7, 2024 07:25
-
-
Save Shilo/30f0bb56f5ec6d7fd6705d06be5a7cd9 to your computer and use it in GitHub Desktop.
FPS counter in Godot 4.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Label | |
func _process(_delta: float) -> void: | |
text = format_number(Engine.get_frames_per_second()) + " FPS" | |
func format_number(number: Variant, thousand_separator: String = ",") -> String: | |
var number_str: String = str(number) | |
var start_index: int = number_str.find(".") | |
if start_index == -1: | |
start_index = number_str.length() | |
for i in range(start_index - 3, 0, -3): | |
number_str = number_str.insert(i, thousand_separator) | |
return number_str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment