using UnityEngine;
using System.Collections;
public class FPS : MonoBehaviour {
private float m_timer;
private int m_frameCounter;
public float m_updateInterval = 0.5f;
public float m_fps;
public System.Action<float> m_fpsUpdateCallback;
// Use this for initialization
void Start () {
m_timer = 0;
m_frameCounter = 0;
}
// Update is called once per frame
void Update () {
m_timer += Time.deltaTime;
m_frameCounter++;
if(m_timer > m_updateInterval)
{
m_fps = m_frameCounter / m_timer;
m_frameCounter = 0;
m_timer = 0;
if (m_fpsUpdateCallback != null)
{
m_fpsUpdateCallback(m_fps);
}
}
}
}
using System.Collections;
public class FPS : MonoBehaviour {
private float m_timer;
private int m_frameCounter;
public float m_updateInterval = 0.5f;
public float m_fps;
public System.Action<float> m_fpsUpdateCallback;
// Use this for initialization
void Start () {
m_timer = 0;
m_frameCounter = 0;
}
// Update is called once per frame
void Update () {
m_timer += Time.deltaTime;
m_frameCounter++;
if(m_timer > m_updateInterval)
{
m_fps = m_frameCounter / m_timer;
m_frameCounter = 0;
m_timer = 0;
if (m_fpsUpdateCallback != null)
{
m_fpsUpdateCallback(m_fps);
}
}
}
}
4369

被折叠的 条评论
为什么被折叠?



