Unity Screen.SetResolution in Android


    1.    #pragma strict
    2.    @script AddComponentMenu("Resolution/Change Resolution")
    3.   
    4.    private var resolutions : Resolution[];
    5.    private var recommended : Resolution;
    6.    var fullScreen : boolean = true;
    7.    private var posRes : int = 0;
    8.    private var totalRes : int = 0;
    9.    private var curRes : String;
    10.   
    11.    function Start() {
    12.   
    13.        // get all the resolutions that the machine can run
    14.        resolutions = Screen.resolutions;
    15.        totalRes = resolutions.Length;
    16.        // get the desktop resolution and set as the resolution of the game in full screen mode (note that this will only work if the player start in the windowed mode)
    17.        recommended = Screen.currentResolution;
    18.       
    19.        // Switch to the desktop screen resolution in fullscreen mode and adjusts the display info
    20.        Screen.SetResolution (recommended.width, recommended.height, fullScreen);
    21.        curRes = Screen.currentResolution.width+"x"+Screen.currentResolution.height;
    22.   
    23.    }
    24.   
    25.    function OnGUI() {
    26.   
    27.        GUILayout.Label("Actual Resolution: "+curRes);
    28.        fullScreen = GUILayout.Toggle(fullScreen, " use fullscreen");
    29.        if(GUILayout.Button("Change Resolution"))
    30.        {
    31.            if(posRes < totalRes)
    32.                posRes++;
    33.            else
    34.                posRes = 0;
    35.               
    36.            Screen.SetResolution(resolutions[posRes].width, resolutions[posRes].height, fullScreen);
    37.            curRes = resolutions[posRes].width+"x"+resolutions[posRes].height;
    38.        }
    39.       
    40.        if(GUILayout.Button("Exit"))
    41.            Application.Quit();
    42.   
    43.    }

이 블로그의 인기 게시물

둘 중 누군가 그녀를 죽였다, 범인 해설

[MAC OS X] mds_stores 100% CPU usage

tips more on unity ...