How do i show the current number of games running frames in unity?

Source: Internet
Author: User

Welcome to Unity Learning, unity training, Unity Enterprise training and education zone, there are many u3d resources, u3d training videos, u3d tutorials, U3d Frequently asked questions, U3d Project source code, we are committed to creating the industry Unity3d training, learning the first brand.

1. First create a new JS script in the project, double-click the script to edit, the code is as follows

var updateinterval = 0.5;

private var accum = 0.0; FPS accumulated over the interval
private var frames = 0; Frames drawn over the interval
private Var timeleft:float; Left time for current interval

function Start ()
{
if (!guitext)
{
Print ("Framespersecond needs a guitext component!");
Enabled = FALSE;
Return
}
Timeleft = UpdateInterval;
}

function Update ()
{
Timeleft-= Time.deltatime;
Accum + = Time.timescale/time.deltatime;
++frames;

Interval ended-update GUI text and start new Interval
if (timeleft <= 0.0)
{
Display fractional digits (F2 format)
Guitext.text = "" + (Accum/frames). ToString ("F2");
Timeleft = UpdateInterval;
Accum = 0.0;
frames = 0;
}
}

2. Add to Guitext after writing

For more highlights, please click http://www.gopedu.com/

How do i show the current number of games running frames in unity?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.