Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking out the garbage #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Assets/Unity FPS counter with buffer/FPS Counter/FPSCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class FPSCounter : MonoBehaviour
static Transform stTr;
static GameObject[] stLines;
static int stNumLines;
static string[] displayBuffer;
static WaitForSeconds graphWait;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -59,6 +61,13 @@ void Awake()
img.color = graphColor;
}

graphWait = new WaitForSeconds(graphUpdate);
displayBuffer = new string[highestPossibleFPS + 1];
for (int i = 0; i <= highestPossibleFPS; i++)
{
displayBuffer[i] = "FPS: " + i.ToString();
}

StartCoroutine(DrawGraph());

//---------------------------------
Expand All @@ -73,7 +82,7 @@ void Update()
//---------------------------------

curCount = StFPS.Counter(frameUpdate, Time.deltaTime);
counterText.text = "FPS: " + curCount.ToString();
counterText.text = displayBuffer[curCount];

//---------------------------------
}
Expand All @@ -88,7 +97,7 @@ IEnumerator DrawGraph()

while (true)
{
yield return new WaitForSeconds(graphUpdate);
yield return graphWait;

GameObject obj = GiveLine();
Image img = obj.GetComponent<Image>();
Expand Down