- Home /
Unity GUI with Android
I'm adjusting GUI for a finished app for Android, and the previous developer used Unity's GUI. I'm adjusting the ratio's for position and scale; however, the relations are not the same on the build as what I assign in the inspector. Does Unity Android have an extremely bugged out version of the GUI? (Using GUITexture). I'm just wondering if anyone else has used this and gotten correct proportional placement by setting the position and pixel inset.
I really don't want to re-do the system.
EDIT:
Using Unity's GUITexture:
The problem with this specific texture is that it is pushed off screen when deployed to android.
I don't understand the question.
What do you mean when you say "adjusting the ratio's for position and scale."
If you want to scale your GUI, you need to scale the rectangles used to draw the controls in your code.
We use Unity's GUI to build resolution independent GUIs for $$anonymous$$ac, Windows, Web, iOS, and Android. We've never had any issues with Android.
using Unity's GUITexture components. The elements are static, so I don't modify size or scale through code.
I've used Unity's GUI through code, but UIToolkit works much better for me. I'll be going that route if adjusting the position (from a value from 0~1 considering position is based off of screen size) doesn't work.
Bumpity. No direct answer? I'm just curious as to whether using only GUITexture is possible to correctly position textures on different devices
Answer by SirGive · Dec 30, 2011 at 02:40 PM
From what I can tell, basic placement with GUITexture doesn't keep its relative position when building to Android. I don't know if this is a bug or what, but the best solution I can find is to place GUI elements through code and position them with ratio's based off of the screen height and width.
So if anyone else has this problem, then yes:
You are going to need to re-do the system using code.
I'm having some problems with GUITextures on Android as well, and I was wondering if it might be related. When you were having trouble with placement, did you also experience that the GUITexture.HitTest() function returned weirdly offset positions?
Yes, that was the exact same problem that I was having. I ended up using UIToolkit and completely redo-ing the system from scratch
Answer by ina · Dec 29, 2011 at 01:22 PM
Taking a guess at your question...
1) The default GUI Skin may be setting some unexpected offset and size differences. Workaround: create a new gui skin, set all the borders, etc to 0.
2) Some things are in screen resolution coordinates and other things are reduced to a 0 to 1, where 0 is either the leftmost or topmost, and 1 the respective extreme
Thanks, I'll try that. and the 0's are intentional as well as the 1's. Top left corner, with a constrained 50x50 texture. Then move the the texture down 50 pixels. This would snap it to the top left, which works in the editor. Not in deployment.
I fear that creating a new gui skin won't be much of an effective workaround. I'm not using any scripts for the texture creation or positioning, just Unity's built in GUITexture.
That is unless there is a way to access the default gui skin that is used by Unity (as I'm having quite some trouble finding it).
Your answer
Follow this Question
Related Questions
Android Resolution Problem 1 Answer
GUITexture with Sphere Collider 2 Answers
GUITexture and GUIText on android 2 Answers
Android tablet 10.1 and guiTexture gui placement with unity 0 Answers