Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

AppController.mm 30fps limit on iPad

Discussion in 'Scripting' started by caseyboundless, Apr 16, 2014.

  1. caseyboundless

    caseyboundless

    Joined:
    Oct 17, 2011
    Posts:
    590
    So I made a test scene with just a gui text with the fps counter off Unity's Wiki and build it to my ipad mini 2. Its only getting 30fps? I read somewhere you can change the AppController.mm to 60fps. How do I do this? I also have Application.TargetFrameRate = 60; set in Awake.
    My full game will run 60fps on webplayer just fine. 120+ fps in unity. Only 30fps on my ipad. All shaders are mobile and everything is pretty much compressed. Only around 10-15 objs at a time in the game.


    Picture off my ipad mini 2
    Picture of quality setting

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class FPS : MonoBehaviour
    5. {
    6.    
    7.     // Attach this to a GUIText to make a frames/second indicator.
    8.     //
    9.     // It calculates frames/second over each updateInterval,
    10.     // so the display does not keep changing wildly.
    11.     //
    12.     // It is also fairly accurate at very low FPS counts (<10).
    13.     // We do this not by simply counting frames per interval, but
    14.     // by accumulating FPS for each frame. This way we end up with
    15.     // correct overall FPS even if the interval renders something like
    16.     // 5.5 frames.
    17.    
    18.     public  float updateInterval = 0.5F;
    19.    
    20.     private float accum   = 0; // FPS accumulated over the interval
    21.     private int   frames  = 0; // Frames drawn over the interval
    22.     private float timeleft; // Left time for current interval
    23.    
    24.     void Awake()
    25.     {
    26.         Application.targetFrameRate = 60;
    27.    
    28.     }
    29.  
    30.  
    31.  
    32.  
    33.     void Start()
    34.     {
    35.         if( !guiText )
    36.         {
    37.             Debug.Log("UtilityFramesPerSecond needs a GUIText component!");
    38.             enabled = false;
    39.             return;
    40.         }
    41.         timeleft = updateInterval;  
    42.     }
    43.    
    44.     void Update()
    45.     {
    46.         timeleft -= Time.deltaTime;
    47.         accum += Time.timeScale/Time.deltaTime;
    48.         ++frames;
    49.        
    50.         // Interval ended - update GUI text and start new interval
    51.         if( timeleft <= 0.0 )
    52.         {
    53.             // display two fractional digits (f2 format)
    54.             float fps = accum/frames;
    55.             string format = System.String.Format("{0:F2} FPS",fps);
    56.             guiText.text = format;
    57.            
    58.             if(fps < 30)
    59.                 guiText.material.color = Color.yellow;
    60.             else
    61.                 if(fps < 10)
    62.                     guiText.material.color = Color.red;
    63.             else
    64.                 guiText.material.color = Color.green;
    65.             //  DebugConsole.Log(format,level);
    66.             timeleft = updateInterval;
    67.             accum = 0.0F;
    68.             frames = 0;
    69.         }
    70.     }
    71. }




    #define kFPS 60.0 in AppController.mm doesn't work.
     

    Attached Files:

    Last edited: Apr 16, 2014
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Nope, that was years ago. The correct way is to use Application.targetFrameRate = 60.

    --Eric
     
  3. caseyboundless

    caseyboundless

    Joined:
    Oct 17, 2011
    Posts:
    590
    Then why would my ipad mini 2 only run at 30fps on a blank scene?
     
  4. bigdaddy

    bigdaddy

    Joined:
    May 24, 2011
    Posts:
    153
    what do you get if you remove the guiText and just write out to the log (using Debug.Log)?
     
  5. caseyboundless

    caseyboundless

    Joined:
    Oct 17, 2011
    Posts:
    590
    Its 30fps
     
  6. jonSG

    jonSG

    Joined:
    Mar 26, 2014
    Posts:
    18
    What is your VSync Count set to?
     
  7. caseyboundless

    caseyboundless

    Joined:
    Oct 17, 2011
    Posts:
    590
    void Awake()
    {
    Application.targetFrameRate = 60;
    // Turn off v-sync
    QualitySettings.vSyncCount = 0;
    }