mirror of
				https://github.com/DerTyp7/fps-citybuild-unity.git
				synced 2025-10-31 05:07:08 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			478 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			478 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| 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";
 | |
|     }
 | |
| }
 | 
