FPS is an important indicator of game performance, Unity is a cross-platform engine tool, so there is no uniform qualification of his frame rate.
In the PC platform, generally the higher the better, the higher the FPS, the more smooth the game.
In the mobile phone platform, the general flow index of 60 frames, can run to 60 frames, is very smooth experience, and then a high difference is very small, and the number of frames is too high, will consume CPU and GPU, will lead to heat and power consumption.
1.unity3d How to set the frame number FPS
After 3.5 versions, the application.targetframerate can be set directly. You can modify the script directly.
Using unityengine;using System.Collections;
public class Setfps:monobehaviour {void Awake () {Application.targetframerate = 60;//here limit 60 frames}}
The default parameter is-1, which will render the game as fast as possible on all platforms, up to 50~60 frames on the web platform.
It is important to note thatUnder Edit/project setting/qualitysettings, if VSync is set, the Targetframerate setting will be invalid. The two are conflicting relations. See the following script for details, the latest address:
Http://docs.unity3d.com/Documentation/ScriptReference/Application-targetFrameRate.html
2. How to view the current frame number fps?
Using unityengine;using System.Collections; [System.Reflection.Obfuscation (Exclude = True)]public class Debugscreen:monobehaviour {//Use this for INITIALIZATIONVO ID Start () {}//Update is called once per framevoid update () {Updatetick ();} void Ongui () {drawfps (); private void Drawfps () {if (Mlastfps >) {gui.color = new color (0, 1, 0); } else if (Mlastfps > +) {gui.color = new color (1, 1, 0); } else {gui.color = new color (1.0f, 0, 0); } GUI. Label (New Rect (.), "FPS:" + mlastfps); } private Long mframecount = 0; Private long mlastframetime = 0; static long mlastfps = 0; private void Updatetick () {if (true) {mframecount++; Long ncurtime = Ticktomillisec (System.DateTime.Now.Ticks); if (Mlastframetime = = 0) {Mlastframetime = Ticktomillisec (System.DateTime.Now.Ticks); } if ((Ncurtime-mlastframetime) >=) {Long fps = (long) (Mframecount * 1.0f /((ncurtime-mlastframetime)/1000.0f)); Mlastfps = fps; Mframecount = 0; Mlastframetime = Ncurtime; }}} public static long ticktomillisec (long tick) {return tick/(10 * 1000); }}
[Unity3d] View and set the number of game frames fps