TO ANYONE HAVING PROBLEMS FINDING IT: at least in the 2021.3.0f1 LTS that i'm using it's not in the package manager and has now been implemented into the game window, simply go on game, click on game at the top left of the viewport and click simulator, hope this helps!
For Android you can simply go into your Player Settings and Uncheck "Render outside safe area" this has the same affect for every Android build Unfortunately Apple doesn't provide any functionality for it so you'll have to use the Safe Area like described in this video. Fast and easy tutorial - thank you Hooson
In Unity 2020.3.6 this does not work in the Awake function for me but in the Start function. Int 2020.3.5 it works in the Awake function. Looking at the forums this seems to be a bug that pops up with Safe Area and Awake.
One thing that would've been lovely is that before start coding, you'd have given a quick overview of the logic and the goal. Just to know what we're aiming for, the good old "plan before coding" hehe
How would you alter the code so that it does not need to support upside down, and ignore notch when flipped so you don't lose the bottom are in portrait mode?
implemented! works well! but after this calculations, from some reason the top and bottom has some gap compared to the device simulator's safe area. i would like to identify exactly that area. any ideas?
Edit for anyone going thru this, Unity build settings itself has an option to render outside of notch area now. I think its a better option than using the script. Precise and well done. Well deserved Like.
Hey Hooson, thank you so much! Directly subscribed! Exactly what I was searching for. It works perfectly when I run a simulator device. But I get a problem starting the game inside the scene view. Then everything is very weirdly formatted. Do you have an idea how to fix that? The workaround would be to always go to simulator first, before starting the game, but maybe there is something easier, just for developers sake?
Hi! I think you need to anchor your UI correctly. Check on your UI's Rect Transform, make sure the anchor point for your UI are anchored to the top and bottom of the screen!
@@hoosontech all I want to say is thanks 😊 alotttttt buddy , we need more these types of android tutorials, now I realised that making an android game as you first game is more hard than making a game for windows , I wanna thank you for your efforts that you are doing and the special thing is replied instantly thank youuuu
How can i apply this to my Background? If i move my background image to the "SafeArea"Object in the Canvas, the background is gone. For the UI it works perfectly, thanks!
Good stuff, good stuff. I think notches are the most annoying, least useful and worst design decision ever conjured by the mobile device companies. It's the worst idea ever and makes everything more complicated for no good reason from software standpoint, bezels were never problematic until the mobile companies' designers got bored and got rid of them...
Yes the script works for landscape as well. Simply change the device orientation to landscape mode and anchor your UI correctly. Your UI will be in the "safe area" of the device when you click play.
TO ANYONE HAVING PROBLEMS FINDING IT: at least in the 2021.3.0f1 LTS that i'm using it's not in the package manager and has now been implemented into the game window, simply go on game, click on game at the top left of the viewport and click simulator, hope this helps!
For Android you can simply go into your Player Settings and Uncheck "Render outside safe area" this has the same affect for every Android build
Unfortunately Apple doesn't provide any functionality for it so you'll have to use the Safe Area like described in this video.
Fast and easy tutorial - thank you Hooson
fuck apple. Thank you very much bro!
thanks bro that is really helpful.
Thanks for your helpful info 😃
Terrible advice. You disable the part of the screen completely. It's better to render outside of safe area.
Wow. A really good tutorial. Directly at the beginning you are showing what this tutorial is about and then show it step by step.
You have most important tutorials that it is impossible to find by simple search. Thank you very much
Really Helpful video Thank you so much❤ I hadn't thought of this problem yet 🤔 but, now I have a great solution 😌
I have been searching and searching for exactly what you had just demonstrated. Thank you for your tutorial.
In Unity 2020.3.6 this does not work in the Awake function for me but in the Start function. Int 2020.3.5 it works in the Awake function. Looking at the forums this seems to be a bug that pops up with Safe Area and Awake.
Thanks for the clean, simple and easy to follow tutorial on this topic.
One thing that would've been lovely is that before start coding, you'd have given a quick overview of the logic and the goal. Just to know what we're aiming for, the good old "plan before coding" hehe
wow great tutorial bro , I have been searchin long time for this .
Excellent video, thank you Hooson from 2 years ago
Thank you so much!! Great and easy tutorial!
good job bro just keep it up.just keep posting these kind of videos and good luck
thanks a lot for this clarifying tutorial
FROM THE BOTTOM OF MY HEART THANK YOU
WOOOOWWW, this is legit tutorial that i need...THANNKK YOU VERYYY MUCHH!!!
Amazing, thanks for all tips and the script works very good!!!
THANK U SOOOO MUCH U SAVED MY LIFE LIKE LITERALLY
I found peace while learning
What a great tutorial. Thank you very much. Subscribed!
Great Stuff!! Pretty simple.
Wow...
Awesome 👌
HONESTLY!
THANK YOU SO MUCH!
JUST PERFECT 🙏👍
This is tutorial that i need for long timeeeee ty sir really ty to u
This code does not work on unity 2023.2.3f1, anyone got this same issue or found a way around it? Thank you
How would you alter the code so that it does not need to support upside down, and ignore notch when flipped so you don't lose the bottom are in portrait mode?
fantastic and straight forward.
Thank you very much, exactly what I needed.
implemented! works well!
but after this calculations, from some reason the top and bottom has some gap compared to the device simulator's safe area. i would like to identify exactly that area.
any ideas?
Yes, that is in case they flip the phone upside down, IM having same issue, and my apps dont need to support upside down phone.
@@54bonesgames85 : ( i dont remember the problem anymore, but I think it was another one.
Simple and informative!
Thank you
This is so awesome. Thanks so much!
10/10 life saver thank you for being a legend.
Hey, its not working well for me, there is still some part of notch where its drawing the UI
This was really helpful, thank you!
Hey I tried making this a function to call, so that it will update when the screen orientation changes, but it does not work. Any ideas?
Edit for anyone going thru this,
Unity build settings itself has an option to render outside of notch area now. I think its a better option than using the script.
Precise and well done. Well deserved Like.
Very clever Thanks
Great video!
Hey Hooson, thank you so much! Directly subscribed! Exactly what I was searching for. It works perfectly when I run a simulator device. But I get a problem starting the game inside the scene view. Then everything is very weirdly formatted. Do you have an idea how to fix that? The workaround would be to always go to simulator first, before starting the game, but maybe there is something easier, just for developers sake?
Fixed it by adding "if (!Debug.isDebugBuild)" around the logic, and use a simulator without notch to develop again
This is incredible! Thanks a lot
Great tutorial! Thank you :D
nice video, how can you show it also in the editor? I tried [ExecuteAlways] but it doesn't work
Just what I needed, thanks!
Don't you think that it can be simple achieved by marking unchecking "render outside safe area" in unity project settings.
buddy i am doing exactly what ypu said but when I play all the UI elements got dissaperad
help plz
Hi! I think you need to anchor your UI correctly. Check on your UI's Rect Transform, make sure the anchor point for your UI are anchored to the top and bottom of the screen!
@@hoosontech all I want to say is thanks 😊 alotttttt buddy , we need more these types of android tutorials, now I realised that making an android game as you first game is more hard than making a game for windows , I wanna thank you for your efforts that you are doing and the special thing is replied instantly thank youuuu
I'm glad I could help! I will continue to improve and produce great content! Wish you all the best for your first mobile game! 👍
Do this works for computers too?
How can i apply this to my Background? If i move my background image to the "SafeArea"Object in the Canvas, the background is gone. For the UI it works perfectly, thanks!
Simply drag your background out of the "SafeArea" object. Your background should be covering the entire screen.
@@hoosontech hello
please the code didn't worked for me ??
i get missing a using directive or assembly reference???
Good stuff, good stuff. I think notches are the most annoying, least useful and worst design decision ever conjured by the mobile device companies. It's the worst idea ever and makes everything more complicated for no good reason from software standpoint, bezels were never problematic until the mobile companies' designers got bored and got rid of them...
Thank you so much! if it doesn`t work, add using UnityEngine.UI;
Will this apply for landscape ?
Yes the script works for landscape as well. Simply change the device orientation to landscape mode and anchor your UI correctly. Your UI will be in the "safe area" of the device when you click play.
Amazing!
thanks!!!
I like video 🤗🤗🤗
Here is the script for those dont want to write
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Never gonna give you up
using UnityEngine;
using UnityEngine.UI;
public class SafeArea : MonoBehaviour
{
RectTransform rect;
Rect safeArea;
Vector2 minVec;
Vector2 maxVec;
void Awake()
{
rect = GetComponent();
safeArea = Screen.safeArea;
minVec = safeArea.position;
maxVec = minVec + safeArea.size;
minVec.x /= Screen.width;
minVec.y /= Screen.height;
maxVec.x /= Screen.width;
maxVec.y /= Screen.height;
// Never Gonna let you down
rect.anchorMin = minVec;
rect.anchorMax = maxVec;
}
}
Never gonna tell a lie, and hurt you!
I hope that when you get a million subscribe you won't forget your first subscribe and 100th subscribe🥺
👍🏻👍🏻👍🏻
Easy to understand!! Thank you.