Skip to content

Commit

Permalink
#4 Added counter in screen.
Browse files Browse the repository at this point in the history
Still needs to be an option and such, but the show code is there
  • Loading branch information
jellewie committed Sep 5, 2018
1 parent aac52d8 commit 674b7e4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Assets/_Code/Standalone/FPSDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ public class FPSDisplay : MonoBehaviour

void Update()
{
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
}
void Start()
{
if (PlayerPrefs.GetInt("FPSCounter", 0) == 1) //If FPS it set to show
{
InvokeRepeating("FPS", 0, 0.1f); //Repeatedly show FPS count (refresh every 0.01s)
}
InvokeRepeating("CalculateFPS", 0, 0.1f); //Repeatedly update FPS count (refresh every 0.01s)
}
void FPS()
void CalculateFPS()
{
float msec = deltaTime * 1000.0f;
float fps = 1.0f / deltaTime;
FPSCounter.text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
float msec = deltaTime * 1000.0f;
float fps = 1.0f / deltaTime;
FPSCounter.text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
}
public void _SetTargetFrameRate(int MaxFPS)
{
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = MaxFPS;
Debug.Log(Application.targetFrameRate);
}
}
Binary file modified Library/InspectorExpandedItems.asset
Binary file not shown.
Binary file modified Library/ScriptAssemblies/Assembly-CSharp.dll
Binary file not shown.
Binary file modified Library/ScriptAssemblies/Assembly-CSharp.dll.mdb
Binary file not shown.
Binary file modified Library/assetDatabase3
Binary file not shown.

0 comments on commit 674b7e4

Please sign in to comment.