Author Topic: iPhoneX safe area support  (Read 10457 times)

SamiK

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
iPhoneX safe area support
« on: October 17, 2017, 03:29:25 AM »
Hi, what's the plan for NGUI to support the safe area requirements in iPhoneX?

As it's now, the buttons on top/bottom of the UI get moved into the area that's not allowed in iPhoneX. Any pointers on how to hack this functionality in to the existing NGUI 3.x would be greatly helpful too. We're currently using version 3.7.9.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: iPhoneX safe area support
« Reply #1 on: October 19, 2017, 02:33:53 AM »
Assuming you're doing anchoring, seems like it would be a simple matter of adjusting the anchors. If you anchor everything to a UIWidget that's then anchored to the UIRoot, you can adjust that widget's offsets on iPhoneX to account for the restricted area. So basically all you need to do is adjust a single widget's dimensions to fix the problem.

CoachCarter9

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: iPhoneX safe area support
« Reply #2 on: November 03, 2017, 10:47:57 AM »
Currently in my setup, each UI Window is setup is a separate prefab with a UIPanel at its root for depth handling.

If I'm understanding correctly, your approach would be to add an anchored UIWidget under each window's prefab and reanchor all of the widgets in that UI to the new UI Widget. That's quite a bit of rework given the number of UIs I have to deal with.

Is there a different alternative to what I mentioned; such as changing the top level UIPanel's clipping to match a preset UIWidget at runtime?
« Last Edit: November 03, 2017, 11:07:50 AM by CoachCarter9 »

MigrantP

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: iPhoneX safe area support
« Reply #3 on: November 04, 2017, 05:21:04 PM »
I've been playing around with this and discovered what seems to be a good alternative: changing the camera's viewport.

You can get Unity's sample safe area plugin here: https://bitbucket.org/p12tic/iossafeareasplugin

Modify it to instead set the NGUI camera's pixelRect to exactly the safe area rect, and voila - exactly correct letter boxing. It's working out great in my tests and I'm putting it into my game next.

serhilk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: iPhoneX safe area support
« Reply #4 on: November 28, 2017, 04:29:54 AM »
I like the solutions that you tell in this posts, but if I want to setup a set of ui elements that are full screen and over them I want to define a safe area zone in which I will add all my interactions like buttons how I can achieve this the best way?

I tested the solution about changing the NGUI camera's pixelRect and it works perfectly but then I will need another camera that will be full screen to work with all the full screen visuals?


this is a very basic example of what I want to achieve but with 2d elements as a background image instead of a 3d world.

What do you think?

Thanks in advance