- Home /
Android Auto scale backgorund for any resolution
hi...i hope to make now a good question because in 2 weeks i didn`t found a good Answard for this...
So, my 2d game in unity for android is almost ready, but...when i test this app on S4, and another 5 divices(with android) my background have a bad scale,
i mean or is too big, or too small i try to use sprites, GUItexture, code, Quad, cube, ALL stuff...
but is same everytime....
NOTE: my orthographic camere have size set to 10... Note(2): sorry for my bad english
Follow the instruction below, GameObject->CreateOther->GUI Texure
You will see the UnityWatermark on screen, now select the the texture and goto inspector menu add your Texture to GUITexture.
To fit GUITexture to any screen size make x and y scale factor 1.
I made this 2 days a go but the texuture is now over my character, and hazards, and i can't(or i don' now how) send to back....
make Texture's z position value greater than character.
Answer by selvap · Mar 18, 2014 at 09:21 AM
the best way to fit the gui texture on every screen is :
Try the follwing this...its works for every screen aspect ratio even for both ios android.
Steps:
1.Create a GUITexture. 2.In GUITexture parameter keep pixel inset to 0.(for everything). 3.Adjust the position and scale value in in Transform inspector. 4.then use this script
using UnityEngine; using System.Collections;
public class GUI_Controller : MonoBehaviour { public Vector2 scaleOnRatio1 = new Vector2(0.1f, 0.1f); private Transform myTrans; private float widthHeightRatio;
void Start () { myTrans = transform; SetScale(); }
void SetScale() { //aspect ratio widthHeightRatio = (float)Screen.width/Screen.height;
//Apply the scale. We only calculate y since our aspect ratio is x (width) authoritative: width/height (x/y)
myTrans.localScale = new Vector3 (scaleOnRatio1.x, widthHeightRatio * scaleOnRatio1.y, 1);
}
} 5.Adjust the scale ratio in script transform... 6.TA ta i....i will works like boss..
thank u..
I will try your script and come back here with my test resoults
Answer by HariKrishnan · Mar 18, 2014 at 08:46 AM
first you will designed for small device. in script you will type the method in update Screen.SetResolution(480,800,true); then you will deployed in different devices then automatically resize.....
i try that0 and when you plah my app on s4 s3 ....the graphics are very bad!!!!
@ZoomStar are you using sprite for bg? if yes then use bellow script, drag and drop bg sprite to BG GameObject. using UnityEngine; using System.Collections;
public class BgTest : $$anonymous$$onoBehaviour {
// Use this for initialization
public GameObject BG;
void Start ()
{
BG.transform.localScale = new Vector3(Screen.width,Screen.height);
}
// Update is called once per frame
void Update () {
}
}
I put this script and now the bg is huge....not fit in my screen size
Your answer
Follow this Question
Related Questions
AndroidJavaProxy no such method exception,AndroidJavaProxy no such proxy method error 2 Answers
Android APK size way too large 2 Answers
Could a mobile app have a service application compiled targetting a higher version of .net? 0 Answers
Can I make my Android game close if you leave the game on the title screen? 1 Answer