프레임 레이트 화면에 표시 하기 fps display

http://wiki.unity3d.com/index.php?title=FramesPerSecond

프레임 레이트 화면에 표시 하기

using UnityEngine;
using System.Collections;
 
public class FPSDisplay : MonoBehaviour
{
 float deltaTime = 0.0f;
 
 void Update()
 {
  deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
 }
 
 void OnGUI()
 {
  int w = Screen.width, h = Screen.height;
 
  GUIStyle style = new GUIStyle();
 
  Rect rect = new Rect(0, 0, w, h * 2 / 100);
  style.alignment = TextAnchor.UpperLeft;
  style.fontSize = h * 2 / 100;
  style.normal.textColor = new Color (0.0f, 0.0f, 0.5f, 1.0f);
  float msec = deltaTime * 1000.0f;
  float fps = 1.0f / deltaTime;
  string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
  GUI.Label(rect, text, style);
 }
}

댓글

이 블로그의 인기 게시물

날짜 시간 시간차 시간 계산 하기

코루틴에서 CallBack 함수 적용하기

C++ 언어 퍼센트 구하는 방법 / 기본 언어 퍼센트 구하는 방법