In Unity3d, you can limit the game frame rate by code settings.
Application.targetframerate=-1;
A setting of 1 indicates an unqualified frame rate.Transfer from Http://blog.csdn.net/huutu
Generally in the mobile phone game we limit the frame rate of 30 OK.
application.targetframerate=30;
But after adding this code to the project, running in unity and discovering that there are no eggs to use ....
Transfer from Http://blog.csdn.net/huutu
Then go to the official website to view information
Http://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html
application.targetframeratepublic static int targetframerate;descriptioninstructs game to try-to-render at a specified FRA Me rate. Setting targetframerate to-1 (the default) makes standalone games render as fast as they can, and web player games to Ren Der at 50-60 Frames/second depending on the platform. Note that setting Targetframerate does isn't guarantee that frame rate. There can fluctuations due to platform specifics, or the game might not achieve the frame rate because the computer is Too slow. If VSync is set in quality setting, the target framerate are ignored, and the Vblank interval is used instead. The Vblankcount property on Qualitysettings can is used to limit the framerate to half of the screens refresh rate (fps Screen can being limited to + FPS by setting Vblankcount to 2) Targetframerate are ignored in the editor.
To the effect that:
Application.targetframerate is used to allow the game to run at a specified frame rate, and if set to 1 let the game run at the fastest speed.
However, this setting will affect the vertical synchronization.
If vertical synchronization is set, then this setting is discarded and is run according to the refresh speed of the screen hardware.
If the vertical sync is set to 1, then it is 60 frames.
If it is set to 2, then it is 30 frames.
Click the menu Editor, projectsetting, qualitysettings to open the render quality settings panel.
Transfer from Http://blog.csdn.net/huutu
1, first off the vertical synchronization, such as.
Set the frame rate to 100
Then the frame rate after the run is 100.
2. Set vertical sync to 1
You can see that the frame rate is beating around 60 frames, completely ignoring the settings in the code.
Transfer from Http://blog.csdn.net/huutu
3. Set vertical synchronization to 2
You can see that the frame rate beats around 30 frames.
Transfer from Http://blog.csdn.net/huutu
Show the frame rate code in the game:
Using Unityengine;using system.collections;using DG. Tweening;public class Newbehaviourscript:monobehaviour {private float m_lastupdateshowtime=0f;//the last time the frame rate was updated; Float m_updateshowdeltatime=0.01f;//time interval for update frame rate; private int m_frameupdate=0;//frame number; private float m_fps=0;void awake () { application.targetframerate=100;} Use the This for Initializationvoid Start () {m_lastupdateshowtime=time.realtimesincestartup;} Update is called once per framevoid update () {m_frameupdate++;if (time.realtimesincestartup-m_lastupdateshowtime> =m_updateshowdeltatime) {m_fps=m_frameupdate/(time.realtimesincestartup-m_lastupdateshowtime); m_FrameUpdate=0;m _lastupdateshowtime=time.realtimesincestartup;}} void Ongui () {GUI. Label (New Rect (screen.width/2,0,100,100), "FPS:" +m_fps);}}
The last sentence in the official documents ... Tested in the editor state is valid:
Unity3d frame rate setting and display frame rate at game run time