Optimize UI For Notch Devices - Easy Unity Tutorial

Поделиться
HTML-код
  • Опубликовано: 19 дек 2024

Комментарии • 71

  • @ukmoxy
    @ukmoxy 2 года назад +10

    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!

  • @bennobear1
    @bennobear1 2 года назад +13

    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

  • @gamedevjourney4231
    @gamedevjourney4231 3 года назад +7

    Wow. A really good tutorial. Directly at the beginning you are showing what this tutorial is about and then show it step by step.

  • @ni3cat
    @ni3cat 2 года назад +1

    You have most important tutorials that it is impossible to find by simple search. Thank you very much

  • @WorldWorrier3273
    @WorldWorrier3273 2 года назад +1

    Really Helpful video Thank you so much❤ I hadn't thought of this problem yet 🤔 but, now I have a great solution 😌

  • @Scene68
    @Scene68 3 года назад +1

    I have been searching and searching for exactly what you had just demonstrated. Thank you for your tutorial.

  • @fehl9249
    @fehl9249 2 года назад +3

    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.

  • @bhupiistersingh4097
    @bhupiistersingh4097 2 года назад +1

    Thanks for the clean, simple and easy to follow tutorial on this topic.

  • @TheSevenEighths
    @TheSevenEighths 3 года назад +2

    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

  • @kyomogu
    @kyomogu 2 года назад

    wow great tutorial bro , I have been searchin long time for this .

  • @user-pe9qg3hg3k
    @user-pe9qg3hg3k 2 года назад

    Excellent video, thank you Hooson from 2 years ago

  • @alexwesterhof1347
    @alexwesterhof1347 Год назад +1

    Thank you so much!! Great and easy tutorial!

  • @davidmason7519
    @davidmason7519 3 года назад

    good job bro just keep it up.just keep posting these kind of videos and good luck

  • @VeeniezMusic
    @VeeniezMusic Месяц назад

    thanks a lot for this clarifying tutorial

  • @mauriciocastro2876
    @mauriciocastro2876 3 года назад +2

    FROM THE BOTTOM OF MY HEART THANK YOU

  • @alfiartya23
    @alfiartya23 3 года назад

    WOOOOWWW, this is legit tutorial that i need...THANNKK YOU VERYYY MUCHH!!!

  • @CarlosCarvajal
    @CarlosCarvajal 2 года назад

    Amazing, thanks for all tips and the script works very good!!!

  • @ecealpay9807
    @ecealpay9807 2 года назад

    THANK U SOOOO MUCH U SAVED MY LIFE LIKE LITERALLY

  • @omerkislakci
    @omerkislakci Год назад

    I found peace while learning

  • @someone4422
    @someone4422 3 года назад

    What a great tutorial. Thank you very much. Subscribed!

  • @SkyAlphaPrime
    @SkyAlphaPrime 2 года назад

    Great Stuff!! Pretty simple.

  • @tnkspecjvive
    @tnkspecjvive 2 года назад

    Wow...
    Awesome 👌
    HONESTLY!
    THANK YOU SO MUCH!
    JUST PERFECT 🙏👍

  • @sdglsle
    @sdglsle 3 года назад

    This is tutorial that i need for long timeeeee ty sir really ty to u

  • @mrkensho3770
    @mrkensho3770 9 месяцев назад

    This code does not work on unity 2023.2.3f1, anyone got this same issue or found a way around it? Thank you

  • @54bonesgames85
    @54bonesgames85 Год назад

    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?

  • @codyswanson
    @codyswanson 11 месяцев назад

    fantastic and straight forward.

  • @thecompletionist605
    @thecompletionist605 2 года назад

    Thank you very much, exactly what I needed.

  • @ShacharOz
    @ShacharOz 3 года назад +1

    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?

    • @54bonesgames85
      @54bonesgames85 Год назад

      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.

    • @ShacharOz
      @ShacharOz Год назад

      @@54bonesgames85 : ( i dont remember the problem anymore, but I think it was another one.

  • @glic7798
    @glic7798 3 года назад

    Simple and informative!
    Thank you

  • @TheSevenEighths
    @TheSevenEighths 3 года назад

    This is so awesome. Thanks so much!

  • @mrvastayan
    @mrvastayan 2 года назад

    10/10 life saver thank you for being a legend.

  • @amitkumarpant9520
    @amitkumarpant9520 3 года назад

    Hey, its not working well for me, there is still some part of notch where its drawing the UI

  • @Bertimble
    @Bertimble 3 года назад

    This was really helpful, thank you!

  • @thePRODYLAN
    @thePRODYLAN 2 года назад

    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?

  • @nikilkumar1000
    @nikilkumar1000 3 года назад

    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.

  • @MohamedElHanoun
    @MohamedElHanoun Месяц назад

    Very clever Thanks

  • @jeffenriquez9929
    @jeffenriquez9929 Год назад

    Great video!

  • @Robbi263
    @Robbi263 2 года назад

    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?

    • @Robbi263
      @Robbi263 2 года назад

      Fixed it by adding "if (!Debug.isDebugBuild)" around the logic, and use a simulator without notch to develop again

  • @Vueltero
    @Vueltero 4 года назад

    This is incredible! Thanks a lot

  • @Bardent
    @Bardent 4 года назад

    Great tutorial! Thank you :D

  • @blackrachmaninov
    @blackrachmaninov Год назад

    nice video, how can you show it also in the editor? I tried [ExecuteAlways] but it doesn't work

  • @gegenton3953
    @gegenton3953 4 года назад

    Just what I needed, thanks!

  • @arslanhazel4729
    @arslanhazel4729 2 года назад

    Don't you think that it can be simple achieved by marking unchecking "render outside safe area" in unity project settings.

  • @kingofroms7224
    @kingofroms7224 4 года назад

    buddy i am doing exactly what ypu said but when I play all the UI elements got dissaperad
    help plz

    • @hoosontech
      @hoosontech  4 года назад

      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!

    • @kingofroms7224
      @kingofroms7224 4 года назад

      @@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

    • @hoosontech
      @hoosontech  4 года назад +1

      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! 👍

  • @vanireethiagocallegari3917
    @vanireethiagocallegari3917 2 года назад

    Do this works for computers too?

  • @1yangman
    @1yangman 4 года назад

    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!

    • @hoosontech
      @hoosontech  4 года назад

      Simply drag your background out of the "SafeArea" object. Your background should be covering the entire screen.

    • @mohanadworld8509
      @mohanadworld8509 3 года назад

      @@hoosontech hello
      please the code didn't worked for me ??
      i get missing a using directive or assembly reference???

  • @TheDravic
    @TheDravic 3 года назад

    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...

  • @acikgozemre
    @acikgozemre 3 года назад

    Thank you so much! if it doesn`t work, add using UnityEngine.UI;

  • @davekene
    @davekene 4 года назад

    Will this apply for landscape ?

    • @hoosontech
      @hoosontech  4 года назад

      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.

  • @martin8447
    @martin8447 2 года назад

    Amazing!

  • @gkstmdahr
    @gkstmdahr 3 года назад

    thanks!!!

  • @nguyentrunghieu6865
    @nguyentrunghieu6865 3 года назад

    I like video 🤗🤗🤗

  • @fv4202x
    @fv4202x 2 года назад +4

    Here is the script for those dont want to write
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    Never gonna give you up

    • @fv4202x
      @fv4202x 2 года назад +1

      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;
      }
      }

    • @fv4202x
      @fv4202x 2 года назад

      Never gonna tell a lie, and hurt you!

  • @pistrantho
    @pistrantho 4 года назад +2

    I hope that when you get a million subscribe you won't forget your first subscribe and 100th subscribe🥺

  • @chermainehoo214
    @chermainehoo214 4 года назад

    👍🏻👍🏻👍🏻

  • @mingyu243
    @mingyu243 3 года назад

    Easy to understand!! Thank you.