Ipod vs iphone apps

Hi,

I am using Unity3D to develop apps for iphone and ipod. The problem I found is that when I want to display some GUI items e.g. buttons, labels or text fields, they look fine on the iphone but very very small in the ipod!

Can you please tell me what should I do to fix this, or does it mean I have to create two different apps, one for each device!?

Thanks

I believe you have different generation devices here. If your devices all run on the same resolution (960x640), then the GUI should be exactly the same. For different device resolutions, Unity has a rundown here :

http://unity3d.com/support/documentation/Manual/iphone-Hardware.html

If this happens, you need to dynamically scale your GUI based on current screen resolution (something that you would be forced to do on a platform build with window-mode enabled). I have a script on the wiki that does this for you by replacing the Rect Struct with the ScaledRect method :

iPhone and iPod have the same resolution. Different generations of iPhones and iPods have different resolutions; namely iPhone 3GS and earlier and the iPod touch 3rd gen and earlier are 1/4 the resolution of current models. You should not create separate apps.

–Eric

Thanks, you are right I have ipod touch 4 and iphone 3G. But how am I going to change the resolution is it inside unity or inside the mobile device it self! Can you please give more details about this. Also the code on the Wiki is in Javascript whereas I am using c#. However, where this code should be placed?

Regards

I read elsewhere that if you develop for iPhone (960x640), that the 3GS phone will automatically scale it down when it runs the app? Someone please correct me if this is wrong.

I always go with something like screenResolution.x * 0.5f to set the position of a GUI object.
You can think percentage than pixel, i feel easier in this way.

And it will always the same ratio on both mormal and hi res.

Can you please clarify more … give more details in steps e.g. 1. do this 2. do that … I tried some of the above suggestions e.g. using 960*640, but still get the GUI items very small on the ipod whereas fits well on the iphone!

Dear Diviner,

I tried your code on the wiki it actually worked only with 320 * 480. But the related labels texts and fields text still small on the ipod and fits well on the iphone. Firstly I converted the code to c# as follows:

===========================================
private static float customWidth = 320f;
//Set this value to the Width of your Game Tab in the Editor
private static float customHeight = 480f;
//Set this value to the Height of your Game Tab in the Editor
public static Rect scaledRect(float x, float y, float width, float height)
{
Rect returnRect;
x = (x * Screen.width) / customWidth;
y = (y * Screen.height) / customHeight;
width = (width * Screen.width) / customWidth;
height = (height * Screen.height) / customHeight;

returnRect = new Rect(x, y, width, height);
return returnRect;
}

=====================================

GUI.Label(scaledRect(Xpos + padding_between, Ypos + padding_bottom + (fieldHeight * (i + 1)), labelWidth, labelHeight2), “username”, textStyle.labelStyle2);

email = GUI.TextField(scaledRect(Xpos + labelWidth + padding_between + 5, Ypos + padding_bottom + (fieldHeight * (i + 1)), fieldWidth2, fieldHeight2), email, 50);

Any one any solution please help.

Just get the screensize x and y inot your start ().

And then in your OnGui() you can do the following

GUI.Label(newRect(0.1f * screensizeX, 0.1f * screensizeY, 0.2f * screensizeX, 0.2f * screensizeY), “hello”);

Well you can also set the new rect in your star()t to reduce memory use.

Remeber the float value are a percentafe between 0 and 1 than define you entire screen height or width.

Thanks sama but this didn’t work at all. all the labels disappeared!?

Remember that the float value is between 0 and 1. that is percentage.
Also the Rect() thin is about (posX, PosY, SizeX, SizeY)

public class ExempleForProportionalButtonForBothiOSDevice : MonoBehaviour 
{	
	
	private float ScreenSizeX = Screen.width;
	private float ScreenSizeY = Screen.height;
	
	void Start ()
	{
		LabelRect = new Rect(0.1f * ScreenSizeX, 0.1f * ScreenSizeY, 0.1 * ScreenSizeX , 0.1f *  ScreenSizeY);

	}
    void OnGUI()
	{
		GUI.Label(LabelRect , "Hello Label");
	}
}

Remember, this example is for getting proportional GUI on each device respecting a percentage value between 0 and 1.

EDIT: About text size, that is Font issue.

You need to creat 2 GUISkin for Normal and HD mode and to insert a different font in each Skin.
if the Normal GUIskin is about 12px font size, you need a 24px font size into the HD one.

What I usually do is the following :

void GUISKIN_Setup ()
	{
		if (Screen_Size_X > 320.0f) 
		{
			GUISkin_A = Resources.Load("GUISkin/GUISkin_HD", typeof(GUISkin)) as GUISkin;
		}
		else
		{
			GUISkin_A = Resources.Load("GUISkin/GUISkin_Normal", typeof(GUISkin)) as GUISkin;

		}			
	}

also Note that the GUISkin can be only loaded from the Resources folder in your project folders.

For those who have same problem … it can be solved by setting the properties of the resolution inside the Unity3d itself into low or standard resolution.

  1. building settings
  2. select ios system for publishing
  3. advanced settings
  4. target resolution (low and standard)

Good Luck

That’s not a good solution because it will make it look ‘ugly’ with iPhone 4 and 4S and newest iPods. Some people don’t like it that if you have low gfx when retina display has been out for almost 2 years. It will just result in getting some bad reviews.