Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
Digitex

Small UI Buttons On Mobile & Package icon

Question

Hello,

 

In order to create a quick main menu UI , i use this old fashionned method:


 

Please login or register to see this code.

That works great when i export it as an Executable for pc but in my mobile phone (Android) , the UI elemnts are too small, what can i do to resolve this issue ?

 

I have another quick question too : Is it possible to get the icon of a unitypackage ? here's a picture to explain :

 

packa.png.77bbbe4d1f15df12e8d03c28a14ac172.png

 

I didn't find the picture inside the package ! :(

 

Thanks,

Edited by Digitex

Share this post


Link to post
Share on other sites

11 answers to this question

Recommended Posts

  • 0

Did you read the post? 

Please login or register to see this quote.

 

  • Like 1

Share this post


Link to post
Share on other sites

  • 0

It simply just looks smaller because the screen is smaller. Make sure your window size in unity is the same scale as you mobile size. Above the game window you will see the window size drop down, then choose the mobile window scale

 

edit: if you still seem to be having troubles, you can scale the button to the window size like: GUI.Button(Rect(50, 50, Screen.width - 100, Screen.height - 100), "button that fills the screen with 50 pixels of padding on each side");

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

Thanks for your answer, 

 

I did as you mentionned and i choosed A Landscape 1240 x 600 . I observed a little change but it didn't resolve the problem

 

I always face this problem: i work on mobile projects and always the UI elements shown in my Game Tab in Unity don't have the same size as the UI in the installed game. For this case, i had to choose big values , the icons appears really big in unity (out of limits), in order to get the size i want in my phone. 

 

Am i doing something wrong ? 

Share this post


Link to post
Share on other sites
  • 0

I don't do many mobile projects but it does sound like something is getting out of place. Are you absolutely positive that is your phones screen resolution? Also, is it not centered or is it not sized correctly? If it's not centered and your using the screen sizing code i posted above, then pixels are for some reason being lost at the edge and you'll have to compensate.

 

place this code on some object in the scene and compare the values from your phone with the unity editors values:

 

function OnGUI()

{

GUILayout.Label("Width: " + Screen.width.ToString() + "  Height: " + Screen.height.ToString());

}

Share this post


Link to post
Share on other sites
  • 0

I'm using a samsung S6 Edge to test out my projects, i looked out in the internet and found this : 

 

Resolution : 1440 x 2560 pixels (~577 ppi pixel density). So i must enter these values in unity ? but how ? create a specific size for S6 ? in width and height ? Fixed resolution or aspec ration ?  ..

 

I also tried the returned value by your function (using Debug.Log) : it returned the values 1024 x 600 ( it was i choosed in the size drop down )

 

Thanks, 

Share this post


Link to post
Share on other sites
  • 0

You have to compare the values from mobile to the editor like I showed previously. That will give the actual display window scale on your device. Once you read what window size is being presented on mobile, create a size for, like you said, an s6 in the unity editor. And if you want it to auto scale for different resolutions, you have to do as I should you before and run it against the window size like Screen.width - 10, etc..

Share this post


Link to post
Share on other sites
  • 0

Thanks again for your answer, 

 

I got your answer except one point : how to get the values from mobile ?

 

with your code, the editor (Play Game mode) will return every time the values of the window size drop down no ? 

 

Regards,

Share this post


Link to post
Share on other sites
  • 0

Thanks for being patient with me, i'm just a beginner ;) 

 

aaaaaaaaa ....  i just understand why i've got 98% of uninstalls in my two games .. it's a question of Resolutions and buttons UI

 

I used to test out in my S6 so i made tests as much as needed to get the right size and get thing working on my phone ... but the others haven't the same phone and screen resolution so everything appears deformed ....

 

So now, in order to make a mobile project optimized for all sized in codes : i must work with Screen.width - (That's when i use C# to code UI elements) ..  But when i create a UI button in Unity what must i put in the transform Scale values ? 

 

Thanks again, 

Edited by Digitex

Share this post


Link to post
Share on other sites
  • 0

I'm not familiar with ugui but I believe there is auto scaling option in the editor

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...