iPhone - Can i tell Unity to run at 60hz rather than 30hz?

I was about to try using

Application.targetFrameRate

till I realised it wasn't present in the iPhone documentation so i presume doesn't exist.

I was keen to try seeing how well my app can go on my 3GS as i'm optimising it to try and reach 30 on older devices. Running at 60hz on >= 3GS would be a nice gain, and improvement for these newer more powerful devices.

Still without that variable, i'm presuming i can't set the speed to anything different than the current ~30hz framerate, unity is using?

I've noticed that there is a kFPS #define in AppController.mm, i presume this can be used? Has anyone had any success with it? It's a bit frustrating as i'd like to scale the target fps by device type. Though i do have Unity iPhone Advanced, being a define and used in some constant variables in AppController.mm i'd presume it'd still be fiddly to expose this in any nice form. Perhaps a better option would be adding switch on device type into AppController.mm directly.. but then the patch would be vulnerable to being overwritten by Unity. Hmm.

Cheers

Here's a step by step breakdown of how to revise your AppController.mm's framerate, for those not comfortable in X-Code.

  1. Build your project in Unity by select Build & Run from the File menu.
  2. Let your app launch in X-Code on your iDevice.
  3. Once your app has launched alt-tab to X-Code.
  4. On the left side of your project in X-Code, you should see a bunch of folders. Click the small arrow next to "Classes" to expand the folder.
  5. The second file in Classes should be "AppController.mm" this is the file you want.
  6. Click on the file, and the contents should display in the main panel.
  7. UNITY has done a fantastic job setting this file up, and all you have to do is change one constant - kFPS.
  8. To find kFPS Hit MacKey + F and search for 30 or kFPS. In my AppController, it is line 97.
  9. Change the "30.0" to "60.0" or whatever max frame rate you want.
  10. Save the file, and return to Unity.
  11. Now, once again select "Build and Run." Unity will have noticed the change and prompt you to save your build. Save in the same area (default) area, and Unity will ask if you want to Replace or Append the project there.
  12. Select Append, and Unity keeps your modified AppController.mm and builds a new version of your game with your new frame rate cap!

Thanks for the help Eric!

Since 3.5(?) you should use Application.targetFrameRate.

Yes, changing kFPS in AppContoller.mm is how you set the framerate. If you use Append when building instead of Replace (or use Command-B for build-and-run), then AppController.mm and other changes you might have made are not overwritten.