Search Unity

is it a problem with GUITextures?

Discussion in 'Android' started by aixaix, Feb 1, 2014.

  1. aixaix

    aixaix

    Joined:
    May 7, 2010
    Posts:
    523
    I have some GUITextures showing on the screen but on the phone they get distorted / blurry...
    Any idea?
     
  2. MDragon

    MDragon

    Joined:
    Dec 26, 2013
    Posts:
    329
    Phone size =/= Computer screen size (pixels-wise)

    Time to do some ratio math! If you didn't know, GUITextures use the transform position in camera coordinates (or I may have the name backwards), where the top right is (1,1) and the bottom left is (0,0) (also the z is what goes on top of what, for other textures).

    With that mini lesson in mind, put the GUITexture nearest to where it is (as in, if you want it around the top left, set the GUITexture to (0,1)- watch out for parents). Then use pixelInset (http://docs.unity3d.com/Documentation/ScriptReference/GUITexture-pixelInset.html) to position the GUITexture. However, the trick is to use ratios. For example....
    -width: Screen.width/5
    -height: Screen.height/3
    -X: (test this out to figure it out) (like negative Screen.width/5)
    -Y: (see X note)

    I had to do that for every single one of my GUITextures. After the initial conversion of everything to ratios, adding new GUITextures is a breeze.

    Have fun! ;)
     
    Last edited: Feb 1, 2014