I'm trying to make a script that adjusts the SafeArea of my Canvas when the device is rotated. I've got it almost working and it looks great on-launch, but I'm getting a weird result after rotating that I can't understand: the SafeArea is different depending on whether the app launched in Portrait or Landscape mode.
When I log out the value of Screen.safeArea on an iPhone 12 Pro, for example, I get the following values:
Portrait on launch: (x:0.00, y:102.00, width:1170.00, height:2289.00)
Portrait rotated to Landscape: (x:0.00, y:102.00, width:2532.00, height:927.00)
Landscape on launch: (x:141.00, y:63.00, width:2250.00, height:1107.00)
Landscape rotated to Portrait: (x:141.00, y:63.00, width:888.00, height:2469.00)
The Width/Height values are changing on rotation, which makes sense, but the X/Y offsets are not. Given the particular nature of the iPhone 12, that means there is a big empty space at the top when launching in Portrait and rotating to Landscape but overflowing the notch to the side, and big empty spaces on both sides when launching in Landscape and rotating to Portrait but overflowing the notch to the top.
Is this the expected behavior? I would have thought the "launching in Portrait" and "rotated to Portrait" safeAreas should be the same, right? Is there a way to force-refresh the safeArea or something, to get the proper X/Y values? Or am I misunderstanding how this is supposed to work?
As I mentioned in my comment, I believe this is a bug in the version of Unity you are using. Good news though! According to this bug report, it has been fixed in 2020.1.X, 2018.4.X and 2019.3.X. If you are already in one of these versions, it could be that the bug has returned. If that's the case, I would try one of the alternate versions listed. If no listed versions work, you should report that the bug has regressed.
Related
I have a sin up page that works very well, but when I switch to landscape mode, there is a small black flash on the screen that also disappears very early. flutter
I created a sign up page on flutter but when I switch from portrait to landscape mode, I see a black square appear on the screen before it disappears
When change the device orientation (by rotate the device) an black screen is painted in the bounds
what are the cases that can cause this?
I wanted to share my solution which is quite easy compared to my question above. Maybe it will save someone's time.
the black edge that appears when the device pivots (see image) disappeared during the execution of a release (flutter run apk --release).
suddenly everything is going well.
I have a problem when I try to change screens , from iPhone X pro to iPhone 8 ( landscape mode). The button don't resize correctly when I make the change.What should I add to the Canva or buttons to get a better size.(Same issue for the panels)
CanvaInspector
ButtonInspector
First of all, if you want your application to just work in landscape mode, then you can set the Reference Resolution as X:1080 Y:1920, set the Match value as 1 (this is based on how you want your UI to react, so you may want to keep it as 0), set your preview screen size as 1920x1080 Landscape, and try to build your application based on that reference, it will make most of the things easier. Furthermore, if you anchor your UI elements properly, it will react to different resolutions without any problem. For the anchors and pivots, you may want to take a look at the unity documentation for basic layout.
However, if you want your application to work in both portrait and landscape mode, then the general idea is more or less the same, you may want to play with your reference resolution and match value (for example, setting the match value as 0.5 will make the UI resize by considering both height and width equally). This documentation can help you to understand it better.
I also know that some developers design different UIs for landscape and portrait mode separately and then activate/deactivate them based on the orientation of the phone. This can also be an option.
I have made app and set it to have portrait orientation for main <activity> in ActivityManifest.xml. It is portrait on all devices except one Chinese noname pad.
There are other apps that handle orientation on that pad correctly.
I expect that in portrait orientation screen width is less then height.
My 2 questions are:-
What is the best way to set orientation? Do I have to check screen width/height and rotate screen accordingly?
How widespread that orientation bug is?
You may see this answer. That was for a Jellybean bug but the same code may apply for other versions aswell.
ActivityManifest.xml way is good enough.
My buggy noname chinese pad is only device that I seen so far.
I've noticed css sprites seem to show 1 more pixel than they should when viewing them on the iphone. My site works perfectly fine on all major desktop browsers on mac and PC. But when I view it on the iphone you can see 1 pixel of the adjacent sprite image.
Anyone encounter this before? Any suggestions on how to cleanly fix this? I know I could just modify all my sprites to have more separation in between them, but is there an easier way?
UPDATE: Tested zooming with safari, and noticed the exact same problem occurs at certain zoom levels on desktop safari
Better late than never:
It's not a bug or a software flaw, it's simple mathematics: the (older) iPhone displays websites at 980px width on a screen that is 320px wide (in portrait mode).
So it's a rounding issue: let's say an element is 50px wide. It is displayed at roughly a third of its size, and that is causing the problem: the iPhone will display it at either 16px or 17px width. Even if it was exactly one third, the problem would remain, and the same applies to various zoom levels, of course.
If it's 16px, you're fine - you have probably noticed that the issue doesn't occur on all your elements. If it's 17px, it means that the element is displayed slightly larger than intended, and the adjacent sprite will show.
I checked apple.om on an iPhone 3G, and even their navigation bar shows some odd little artifacts at the bottom - they're just barely noticeable.
So in theory, it should be enough to add 1px around each sprite. Having to change all these elements is a bummer, but it seems to be the best solution. The problem isn't likely to go away either - the iPhone 4 obviously still scales things down, at least in portrait mode. Not to mention all the other smartphones out there with far inferior screens.
Add another 1px of space between the icons.
.:edit:.
Just noticed that this was one of your proposed solutions. Check the elements with the sprite and make sure that they are the right size. (Double check the rendered border-box model in Firebug).
It could have something to do with how the mobile phone renders items.
I recently deployed my first iPhone app, a simple game, to my testing iPhone for the first time. Everything looks and runs fine on the simulator in Xcode, but on the iPhone the whole image is shifted up about 10 pixels or so. So the gameplay goes slightly offscreen on top and has a slim white/grey bar at the bottom. Has anyone encountered this before? I do have the status bar display turned off, I'm wondering if the device handles that flag differently than the simulator. I also have the rotation hardcoded to be in portraitRight mode at all times, and I have an extra line in the code to make the simulator do that automatically that's apparently not necessary on the device.
Everything is very simple, so I'm not sure where this glitch is coming from or even where to look.
Did you use Interface Builder to create your UI? If you did, then go and check each and every XIB file(s) objects' Size & Position as well as Autosizing in Size Inspector (command-3).
It's very important to check both: your coordinates might have gone wrong after some change you did and autoscaling works in weird ways unless you attach to correct edges. Apple documentation should help http://developer.apple.com/iphone/library/documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html