메뉴 건너뛰기

라이온하트 2nd edition

홈페이지를 새롭게 리뉴얼합니다.

조회 수 129101 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
using UnityEngine;
using System.Collections;

public class Fps : MonoBehaviour 
{

    public UILabel FpsLabel;
    
    public float updateInterval = 0.5F;

    private float accum = 0; // FPS accumulated over the interval
    private int frames = 0; // Frames drawn over the interval
    private float timeleft; // Left time for current interval

    void Awake()
    {
        QualitySettings.vSyncCount = 0;
        Application.targetFrameRate = 60;
    }
    
    void Start()
    {
        timeleft = updateInterval;
    }

    void Update()
    {
        timeleft -= Time.deltaTime;
        accum += Time.timeScale / Time.deltaTime;
        ++frames;
        if (timeleft <= 0.0)
        {
            float fps = accum / frames;
            string format = System.String.Format("{0:F2} FPS", fps);

            FpsLabel.text = format;

            timeleft = updateInterval;
            accum = 0.0F;
            frames = 0;
        }
    }
}

QualitySettings.vSyncCount = 0;
Application.targetFrameRate = 60;

FrameRate은 기본 적으로 60으로 되어 있고, QualitySettings.vSyncCount = 0; 으로 해줘야지만 동작한다.


List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
225 C# 이미지 영역 설정방법 LionHeart 2021.02.16 276245
224 OS PHP WebSocket (웹소켓) 라이브러리 Ratchet, ReactPHP, sandstone LionHeart 2021.01.28 272856
223 C# 표준편차 (볼린저밴드 구현을 위한) LionHeart 2015.04.29 260536
222 OS [스크랩] Nginx(1.9.5) 설치 및 성능테스트 LionHeart 2016.01.23 249572
221 C# FTP upload 기능 구현 LionHeart 2013.11.04 248418
220 C# libevent 및 libev로 네트워크 성능 향상 LionHeart 2013.10.23 226521
219 C# C# XML 쓰고 읽기 LionHeart 2015.02.10 225864
218 OS 리눅스 - 아파치 2.x 트래픽 제한 LionHeart 2014.08.26 225191
217 OS USB 저장장치에 의한 데이터 유출 방지 방법 1 LionHeart 2014.07.22 213684
216 C# How to encrypt and decrypt files using the AES encryption algorithm in C# LionHeart 2020.06.11 212914
215 C# C# FTP 종합 LionHeart 2013.11.04 211237
214 Information 텔레그램 봇(botfather) LionHeart 2018.03.16 205622
213 Android [유니티3D엔진] 안드로이드 유니티 연동_JNI badung007 2013.10.26 191258
212 OS INSTALLING NVIDIA LINUX DRIVERS IN A XEN ENABLED KERNEL LionHeart 2014.08.21 189916
211 Information network simulator 3 (ns-3) overview LionHeart 2013.10.24 185563
210 OS Apache, DDoS 방어모듈 1 LionHeart 2014.10.01 169883
209 C# C# Simple FTP Class LionHeart 2014.01.29 169734
208 OS Realtek 8723be-bt 무선랜 드라이버 (한성 u44x ) LionHeart 2014.07.18 161422
207 OS [스크랩] RHEL/CentOS 7 에서 방화벽(firewalld) 설정하기 LionHeart 2016.01.29 159310
206 C# 웹캠 영상출력 LionHeart 2014.03.31 157167
Board Pagination ‹ Prev 1 2 3 4 5 6 7 8 9 10 ... 12 Next ›
/ 12