Attached is the screenshot from mobile, Setting screenshot from Unity and the code snippet to generate the UI button.
My problem is of scaling the UI generated buttons according to the resolution of different devices, I am breaking my head with every wall since 7 hours but no good, i found different tutorials but couldn’t solve my specific problem.
It is shown in the screenshot of unity the size showing on 16:10 ratio is quite large that is going out off screen but i am unable to get why why why it is showing so small on the device.
Please note that my app is live and i am looking for an urgent response.
using UnityEngine;
using System.Collections;
public class SkinImplementer : MonoBehaviour {
public GUISkin MainSkin = null;
public string buttonTitle = string.Empty;
public Texture2D playButtonImage = null;
public Texture2D LeaderboardButtonImage = null;
public Texture2D AchievementButtonImage = null;
public Texture2D CreditsButtonImage = null;
public Texture2D PlayAgainButtonImage = null;
void OnGUI(){
GUI.skin = MainSkin;
if (Application.loadedLevelName == "TapBallStart") {
if (GUI.Button (new Rect (Screen.width / 2 - 150, Screen.height / 2 - 60, 300, 120), playButtonImage)) {
Application.LoadLevel ("TapBall");
}
} else if (Application.loadedLevelName == "TapBallGameOver") {
if (GUI.Button (new Rect (Screen.width / 2 - 150, Screen.height / 2 - 60, 300, 120), PlayAgainButtonImage)) {
Application.LoadLevel ("TapBall");
}
}
if (GUI.Button(new Rect (Screen.width/2, Screen.height/2+60, 225, 225), LeaderboardButtonImage)) {
//show leaderboard script
Social.ShowLeaderboardUI();
}
if (GUI.Button(new Rect (Screen.width/2-225, Screen.height/2+60, 225, 225), AchievementButtonImage)) {
//show achievement script
Social.ShowAchievementsUI();
}
if (GUI.Button (new Rect (Screen.width / 2 -105, Screen.height / 2 + 285, 210, 120), CreditsButtonImage)) {
Application.LoadLevel ("Credit");
}
}
}