Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. If you're a macOS 10.13 High Sierra user take be sure to read this before updating Unity.
    Dismiss Notice
  5. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  7. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Option to hide iPhone X home indicator + Edge Protection

Discussion in 'iOS and tvOS' started by SweatyChair, Oct 20, 2017.

  1. SweatyChair

    SweatyChair

    Joined:
    Feb 15, 2016
    Posts:
    62
    We have adapted our game to iPhone X design and got a feedback from Apple representatives that they suggested to hide the home indicator in game and enable "Edge Protection" (swipe up once to show home indicator, swipe up again to go back home as said here)

    I believe it's not there yet in Unity? It will be great if Unity can add this in (just an option below "Status Bar Hidden").

    There's a post on how to do this with iOS native code. I don't really understand so better wait for Unity...

    Here is the feature request I made, vote it up if this matters you.

    Screen Shot 2017-10-20 at 5.35.17 pm.png
     
    Last edited: Oct 20, 2017
  2. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    424
    Hi. This feature is in development and will be released in near future.
     
    JohnGate likes this.
  3. SweatyChair

    SweatyChair

    Joined:
    Feb 15, 2016
    Posts:
    62
    Very nice, please do update here if that's implemented in any new version/patch.
     
  4. h0lmie

    h0lmie

    Joined:
    Oct 13, 2015
    Posts:
    2
    You can do it yourself for now if you use Xcode 9.

    Add

    - (BOOL)prefersHomeIndicatorAutoHidden
    {
        return YES;
    }

    To UnityViewControllerBaseiOS.mm
     
    Danar-iHugo and hgbimonti like this.
  5. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    367
    This is for both status and edge protection

    UnityViewControllerBaseiOS.h
    Code (CSharp):
    1.  
    2. @interface UnityViewControllerBase : UIViewController
    3. {
    4. }
    5.  
    6. - (BOOL)shouldAutorotate;
    7.  
    8. - (BOOL)prefersStatusBarHidden;
    9. - (UIStatusBarStyle)preferredStatusBarStyle;
    10. - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures; // add this
    11. - (BOOL)prefersHomeIndicatorAutoHidden; // add this
    12. @end
    13.  
    UnityViewControllerBaseiOS.mm
    Code (CSharp):
    1.  
    2. - (BOOL)shouldAutorotate
    3. {
    4.     return YES;
    5. }
    6.  
    7. // add this
    8. - (BOOL)prefersHomeIndicatorAutoHidden
    9. {
    10.     return YES;
    11. }
    12.  
    13. // add this
    14. - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
    15. {
    16.     return UIRectEdgeAll;
    17. }
    18.  
    19. - (BOOL)prefersStatusBarHidden
    20. {
    21. ....
    22.  
     
  6. sergioabril

    sergioabril

    Joined:
    Jan 11, 2016
    Posts:
    7

    Hi guys,

    Whenever I add this, my home indicator disappears, yes, but as soon as I tap the screen (anywhere, and not even doing a swipe), home indicator appears again. Is this the expected behavior? It makes Home Indicator even more annoying, since my game is a point and click, and you are tapping the screen all the time. I hope I'm missing something :/
     
  7. IvyKun

    IvyKun

    Joined:
    Sep 28, 2013
    Posts:
    39
    I'm using the option for hiding it that unity added on the last patch (Unity 2017.2.0p2) and same thing happens, so I guess it's the expected behaviour.

    I don't see the point on hiding it on any app or games, it's just distracting. I only see it useful if you are watching a video or something like that.
     
    _Daniel_ likes this.
  8. _Daniel_

    _Daniel_

    Joined:
    Feb 28, 2007
    Posts:
    2,498
    I agree that it's primary intention is most likely watching videos. Let's hope that they make it optionally hide completely so that we can take full advantage of the real estate.
     
  9. acproctor

    acproctor

    Joined:
    Oct 28, 2015
    Posts:
    3
    I'm going to give this a test, but if the behaviour is as you've described then I don't think it's the only way to enable edge protection. I was playing Campfire Cooking on an iPhone X and it had edge protection turned on. In that game the home indicator stays low opacity until you actually swipe up on (or near) the home indicator, and doesn't activate on every screen tap.
     
  10. acproctor

    acproctor

    Joined:
    Oct 28, 2015
    Posts:
    3
    Ok, i just ran some builds on 2017.2.0p2 I think the behaviour most people want is just putting on bottom edge protection, and not enabling auto-hide. Auto hide of the bottom bar in unity settings will (as you described) hide the bar completely, but show it full brightness on any screen tap. But if you just set the deferred gesture protection on the bottom bar, it will fade out the bar mostly and will only enable when you swipe near the bar (requiring a double swipe to dismiss your app).

    This is the way Campfire Cooking was behaving, and I think the iOS recommended way. Auto-hiding basically was only recommended for video-player like applications. In fact they don't really recommend doing either option, but I think if your game has issues conflicting with the gesture they're ok with it.
     

    Attached Files:

    _Daniel_ likes this.
  11. SweatyChair

    SweatyChair

    Joined:
    Feb 15, 2016
    Posts:
    62
    @acproctor
    Thanks, we don't have an iPhoneX to test yet and your answer seems solid and we will just fellow~
     
    Last edited: Nov 24, 2017
  12. xianhui1

    xianhui1

    Joined:
    Jan 12, 2017
    Posts:
    1
    Hey, I find your request, you can try to add the following code in the
    UnityViewControllerBase class, and then there are no changes in other places.
    - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures

    {

    return UIRectEdgeAll;

    }
     
  13. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    468
    FYI, I do see a "Hide Home Button on IPhoneX" in Unity 2017.3 f2