- Home /
UI and resolution problems (fine in editor, problem in Android build)
Hello, currently the UI elements in my game is responsive to the screen resolution in the Unity Editor game view. I even tried with many resolutions and Free Aspect view in Unity to test my UI and gives perfect results.
However, after I built the game for Android as APK and installing it in my tablet, the UI seems to be broken, UI elements that I had anchored to the corner doesn't work, some appear offscreen and what should be offscreen became on screen.
I tried changing the build setting to windows and build the game. After I tested it, same problems with the android version.
The UI works perfectly on the editor however, what could be the problem here? Thank you commUnity.
I am also searching for this exact issue's solution. Have not seen this before in my previous 2 commercial projects built with Unity... Like you, the GUI looks fabulous in the Editor, even at the same resolutions as the Android devices, but after building the AP$$anonymous$$, it's quite unuseable... stretched images, elements not aligned anymore, etc.
Try this settings in CanvasScaler component of your UI canvas:
UI Scale $$anonymous$$ode => Scale with screen size
Set reference resolution
Screen match mode => select the one you like more, "expand" should work for 100% cases if you set anchors properly.
I already fixed this issue, using the hard way. I actually recreate all of the UI elements and it seems the problem is fixed. I think the scene file is corrupted or something that makes this problem happened (As all of my UI was not made as a prefab). Or maybe because of I'm using Ctrl-Z in editor while editing UI a lot. Somehow Ctrl-Z sometimes could make the UI broken in the editor. $$anonymous$$ostly with anchors which made the UI looks broken.
I've been having the same problem (stretched images, elements not aligned, GUI elements moving a lot between Editor and build version). I'm currently on Unity 5.1.1.
Has there been any fixes for this? It seems to be a pretty big deal because this prevents us from creating a usable GUI in any build (not just Android for me).
Ctrl-Z may cause this issue? But Ctrl-Z is so useful...
Is any of this documented elsewhere besides this question (which surprisingly doesn't have a lot of people following/commenting).
Did anyone also see a message like this in the logs of the build version?:
"The file 'pathtofile/level5' is corrupted! Remove it and launch unity again! [Position out of bounds!]"
There are a lot of threads that indicate this may be caused by a .js and .cs file having the same name. However, I have no .js scripts in my entire project. Is there another reason for this error message in the logs of the build version?
Answer by jtok4j · Apr 03, 2015 at 04:13 PM
Hmm, Depending on the editor's version (e.g. 4.6 or newer) you may find that your "guitexture"'s actual texture files in the editor has been assigned (automatically) the Texture type of : Sprite...
This caused my project to look great within the GUI of the editor, and then look very strange/messed up with different texture sizes/text coordinates on the screen of the device (android).
So, I changed the "Texture Type" To: Legacy GUI (Sorry, it's a bit longer than that, but I can't remember the whole title.)
Then... surprisingly the textures started showing (within the editor) as they did (messed up) within the actual android build... So, I can now change them to the right size/screen placement and they match (in the editor) what's shown in the actual android build.
Hope this helps anyone who was disappointed/pulling their hair out like I was. (Note: These instructions were for using the "old" Unity GUI system in the 4.6 version of Unity Editor)
I'm having the same issues you did but with Unity Editor 5.1.1
Could not find anything similar to "Texture Type" in this version.
Is there a similar fix for version 5.1.1?