mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2025-10-30 12:37:08 +01:00
Base Rigidbody Movement + FPS counter
This commit is contained in:
21
Assets/Scripts/FPSCounter.cs
Normal file
21
Assets/Scripts/FPSCounter.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class FPSCounter : MonoBehaviour
|
||||
{
|
||||
public TMPro.TextMeshProUGUI fpsText;
|
||||
public float deltaTime;
|
||||
void Start()
|
||||
{
|
||||
fpsText = gameObject.GetComponent<TMPro.TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
|
||||
float fps = 1.0f / deltaTime;
|
||||
fpsText.text = Mathf.Ceil(fps).ToString() + "FPS";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user