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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Target Resolution "Best Performance" override? (solved + code)

Discussion in 'iOS and tvOS' started by thecodes, Sep 4, 2015.

  1. thecodes

    thecodes

    Joined:
    Jul 9, 2015
    Posts:
    20
    Hello,

    On old ipads (Gen2, Gen3), I can't hit my target 30fps in a 3D game without using the best performance option. I'm maxing the renderer according to the xcode GPU report, so I've hit a bandwidth limit of some sort (despite many improvements to the sizes of textures, which didn't get me much and atlassing).

    The issue I have is my menu scene.This screen has a title page and a "play butotn", this screen has no FPS problem, but with the scaling (0.75 or 0.5) imposed by the "Best Quality" setting it looks horrible - especially on the non-retina ipad.

    I would like to go to full res on this scene and back to scaled res (best performance) on for the actual 3D game play. Anyone know a technique? I've exercised my google muscle and found little except for this:

    http://answers.unity3d.com/questions/398920/ios-best-performance-gives-odd-resolutions-unity-4.html

    Thank you,
    Seth
     
  2. thecodes

    thecodes

    Joined:
    Jul 9, 2015
    Posts:
    20
    To be more specific. I want my menu screen to match my splash screen (in full "Best Quality" mode this works perfectly). The only difference between the menu and the splash screen is a "play" button is added after I async load the actual 3d game scene in the background.
     
  3. thecodes

    thecodes

    Joined:
    Jul 9, 2015
    Posts:
    20
    So here is roughly something that works. You can set your iOS to app to best performance but still use the full resolution of the device for menu and cut scenes where you typically don't not FPS issues.

    I did notice that width is always the smaller number on iOS, which was interesting (internally always portrait?).

    In my setup I fade the menu/cut scene in from black, and also fade out to black during the scene exit, so I do these resolution changes when the screen is still black so it doesn't do anything funny visually.

    Code (CSharp):
    1.  
    2. int scaledWidth = -1;
    3. int scaledHeight = -1;
    4.  
    5. void Awake() {
    6.  
    7.  
    8.     if (SystemInfo.deviceType == DeviceType.Handheld) {
    9.  
    10.  
    11.         int devWidth = Display.main.systemWidth;
    12.         int devHeight = Display.main.systemHeight;
    13.  
    14.         Debug.Log ( "devwidth=" + devWidth + " devheight=" + devHeight );
    15.         Debug.Log ( "width=" + Screen.width + " height=" + Screen.height );
    16.  
    17.         // the scaled resolution, we want to remember this because
    18.         // when we need to set it back for performance just as we swap scenes
    19.         scaledWidth = Screen.width;
    20.         scaledHeight = Screen.height;
    21.          
    22.         Screen.SetResolution ( devWidth, devHeight, true);
    23.  
    24.     }
    25.  
    26. }
    27.  
    28. void SwapScene() {
    29.  
    30.     // In my case I load this scene async, and after the user hits the play button
    31.     // I fade to black, and once it's all black I switch it so nothing visually looks odd
    32.     // on the screen
    33.  
    34.     if (scaledWidth != -1)
    35.         Screen.SetResolution ( scaledWidth, scaledHeight, true);
    36.  
    37.     Application.LoadLevel ("some_fancy_scene");
    38.  
    39. }
    40.  
    Note: fixed typo should be == and not = in first condition.
     
    Last edited: Sep 4, 2015