Exemple #1
0
    private IEnumerator FPS()
    {
        for (;;)
        {
            // Capture frame-per-second
            int lastFrameCount = Time.frameCount;

            float lastTime = Time.realtimeSinceStartup;

            // Sets how fast this updates
            yield return(new WaitForSeconds(frequency));

            float timeSpan   = Time.realtimeSinceStartup - lastTime;
            int   frameCount = Time.frameCount - lastFrameCount;

            // Display it
            FramesPerSec  = Mathf.RoundToInt(frameCount / timeSpan);
            FramesPerSecB = frameCount / timeSpan;
            FPSText.text  = FramesPerSec.ToString() + "";

            if (showPrefix == true)
            {
                FPSText.text = "FPS: " + FramesPerSec.ToString() + " (" + ((1.0f / (FramesPerSecB)) * 1000.0f) + " ms)";
            }
        }
    }
Exemple #2
0
        //-----------------------------------------------------------------------------
        // Private Methods
        //-----------------------------------------------------------------------------

        IEnumerator FPS()
        {
            while (true)
            {
                // Capture frame-per-second
                int   lastFrameCount = Time.frameCount;
                float lastTime       = Time.realtimeSinceStartup;

                yield return(new WaitForSeconds(frequency));

                float timeSpan   = Time.realtimeSinceStartup - lastTime;
                int   frameCount = Time.frameCount - lastFrameCount;

                // Display it
                FramesPerSec = Mathf.RoundToInt(frameCount / timeSpan);
                Value        = FramesPerSec.ToString() + " fps";
            }
        }