유니티를 하다보면 성능을 직접확인해야할 때가 많다.
fps 표시하는 코드
using UnityEngine;
using System.Collections;
public class frame_count : 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(100, 100, 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);
}
}
쉐이더(Shader) 와 랜더링 파이프라인(Rendering Pipeline) (2) | 2024.01.18 |
---|---|
[유니티 꿀팁] 유니티가 에디터랑 연결이 안 될때 해결방법 (0) | 2021.10.23 |
Mac OS X 에서 Unity Plugins 빌드하기 (0) | 2021.03.18 |
유니티 - Post Processing (0) | 2020.11.13 |
유니티 - Particle System (0) | 2020.11.12 |