- Home /
How do i fit my android game for all screen sizes and resolution
Hi, everybody am porting my game to android but am having a hard time fitting it to my devices screen can anyone please help me thanks
Fitting what? If GUI then use screen.width and screen.height. Also using plugins like NGUI and tk2d helps with that.
How do i use screen.width and screen.height..In my game i just created guitextures and guitexts and used the transform to position them.Thanks
Answer by KiraSensei · Nov 12, 2013 at 09:44 AM
To position them, you had to put integers to define their coordinates (in pixels). Instead of that, you can use Screen.width and Screen.height to keep proportionality.
I posted a similar question HERE.
here's a screenshot mayb it will be more explanatory.what i want is for the elements in the 480x320 aspect ratio to have the same positioning as the 16:10 aspect ratio without overlapping each other.thanks
Ok, so you also need to change the size of the texts and textures, and make it dependant of Screen.width or Screen.height
I don't know what you used for your text (text mesh, gui texture, ... ?)
If you used text mesh, it is a simple game object, so you just need to resize it by playing with the scale. If you chose to display a texture with GUITexture (like THAT), you need to handle the size of the rectangle (parameters Width and Height of "Pixel Inset") in function of Screen.Weight and Screen.Height (by script). If you used Graphics.DrawTexture, it is the same as before with rectangle parameters (by script again).
for example :
Graphics.DrawTexture(new Rect((Screen.width/2)-8,(Screen.height/2)-8,16,16), crossTexture);
displays a cross exactly in the middle of the screen, whatever the resolution is.
If you used something else, I need to see the code you used to help you more.
thanks for the reply i used a GUITexture like the link you gave how then do i code the Screen.height and Screen.height
Your answer
Follow this Question
Related Questions
How do I set an Android applications resolution? 4 Answers
Screen brightness on Android 2 Answers
How do I rotate an object on one axis to face android touch? 0 Answers
White screen before Splash screen change to black 0 Answers
Flickering screen after Android device lock/unlock,Flickering screen after device lock 0 Answers