Hi Firemaw, thanks for your reply and help! Here are the properties. I will follow the tutorial again and pay more attention. I must have missed something. I don’t see many people complaining about this so it must be me doing something odd. Is there anything out of the ordinary in my properties from what you can see? I have played with multiple options and combinations while working on this issue so something might be changed from what it was ath the beniging :D.
@Hoorza Looks like you have the Canvas and SafeArea set up correct. Your Match scale is unusual, I would normally recommend it at 0.5 for even scaling in both axes.
Again, for the scripts to work, it needs to be running the game either: (1) on a mobile device with a notch; or, (2) using the debug key to simulate iPhone or Android notch in the editor (see “Editor Simulation” heading and SafeAreaDemo.cs script in the tutorial).
You could also check that your anchoring settings are correct on the direct children of the SafeArea object. Make sure you are anchoring them inside the panel and not to out-of-bounds coordinates.
People are mentioning a “tutorial” here, but I’m not seeing it, other than the behanced article, which doesn’t specifically reference this asset, as far as I can tell. Is there a basic tutorial anywhere for this? For example, the asset mentions a simulator, but it’s unclear whether this is something that’s added to the official unity simulator (in which case I don’t see the new devices there), or something that’s standalone (in which case I don’t see a menu where I can open it).
Hi @jd423, I wrote the linked article on the Asset Store page, it is the tutorial for this asset. There is a debug simulator script in the asset that allows you to simulate some common screen safe areas in Editor Play mode (without having to build to device). Since I created this asset many years ago, Unity has since released it’s own screen simulator called the “Device Simulator”. This is a completely separate tool, which you can refer to the Unity documentation for. Unity also has it’s own documentation for Screen.safeArea which these scripts build upon.
Hi, the Safe Area works fine in the Unity Editor, but once exported to a mobile device, it only functions correctly in the default orientation. For example, if the app starts in Landscape mode, the Safe Area is displayed accordingly. However, if the device rotates to Portrait, the Safe Area remains as if it’s in Landscape. Conversely, if the app starts in Portrait, the Safe Area doesn’t adjust correctly when switching to Landscape. I see the system detects orientation changes in the logs, but the Safe Area remains incorrect. How can I fix this?
Hi @vector2497, the code checks orientation every frame and adjusts accordingly. What version of Unity and mobile device are you using? Can you screenshot your hierarchy and the properties on your Canvas and safe area panel?
Hi there, thanks for the reply! I checked online, and it turns out it’s a Unity bug… It happens from time to time whenever Unity updates. I updated Unity from 2022.3.9 to 2022.3.42, and the problem went away.
See here: Unity Issue Tracker - [iOS] Screen.safeArea is incorrectly updated when rotating the device
Great to hear, thanks
Forgot to say… Thank you so much for building this plugin! It helps a lot!
My UI looks good on all devices in Mobile Simulator, including devices without any notch or homebar.
However, if I try switch to normal Game View with resolution 1080x1920, the UI positioning becomes all messed up.
Is that normal? Not really an issue since I can always use Mobile Simulator view, but I’m curious if there’s something wrong.
Hi Kamil, can you share some screenshots of what looks wrong and your SafeArea hierarchy setup and parent panel settings?