Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Nexus 4 resolution problem?

Discussion in 'Scripting' started by GGames, Jul 29, 2013.

  1. GGames

    GGames

    Joined:
    Oct 20, 2012
    Posts:
    66
    Well, Nexus 4 is 1280 x 768 and there is no such resolution option in the Unity simulator...

    When run on the phone itself it is messed up...
    The locations of some things are really messed up.
    I used Screen.width and Screen.height for positioning things.

    When run on my Xperia Ion(1280 x 720) it is perfect.

    How can I test for Nexus 4 in the simulator or how can I fix this?
     
  2. damiantequila

    damiantequila

    Joined:
    Mar 8, 2013
    Posts:
    19
    The most important this is aspect. For example you can test your game on 640x384 resolution.
     
  3. GGames

    GGames

    Joined:
    Oct 20, 2012
    Posts:
    66
    That resolution is not available in the simulator either...
     
  4. GGames

    GGames

    Joined:
    Oct 20, 2012
    Posts:
    66
    bump...
     
  5. cjow

    cjow

    Joined:
    Feb 29, 2012
    Posts:
    132
    What version of Unity do you have installed? 4.2 added the ability to add custom screen resolutions. What damiantequila means is the resolution does not matter, only the aspect ratio. 1280x768 is 16:10 so you could use the default Unity 16:10 aspect ratio which scales to the screen as you resize it or any other option which gives a 16:10 aspect ratio.
     
  6. GGames

    GGames

    Joined:
    Oct 20, 2012
    Posts:
    66
    I have an older version than that...
    Is there any way to test things for me?
     
  7. damiantequila

    damiantequila

    Joined:
    Mar 8, 2013
    Posts:
    19
    In game view choose free aspect and toggle button "stats". You can resize game window and choose correct resolution.
     
  8. sushanta1991

    sushanta1991

    Joined:
    Apr 3, 2011
    Posts:
    305
    i found my solution here, http://answers.unity3d.com/questions/169056/bulletproof-way-to-do-resolution-independant-gui-s.html

    very simple script,

    var native_width : float = 1920; // here give your original width of the screen you are working on
    var native_height : float = 1080; // here give your original height of the screen you are working on
    // now your gui will rescale its self automatically to any resolution
    function OnGUI ()
    {
    //set up scaling
    var rx : float = Screen.width / native_width;
    var ry : float = Screen.height / native_height;
    GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (rx, ry, 1));

    //now create your GUI normally, as if you were in your native resolution
    //The GUI.matrix will scale everything automatically.

    //example
    GUI.Box( Rect(810, 490, 300, 100) , "Hello World!");

    }