Author Topic: iPhone X display NGUI support  (Read 1389 times)

Kafar

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 27
    • View Profile
iPhone X display NGUI support
« on: February 17, 2018, 08:25:24 AM »
Hello,

I read the only one post who talk about this topic (http://www.tasharen.com/forum/index.php?topic=15480.0) but it not is for me.
I have a UI Root and inside it many other UIpanels, UIButtons, etc, all anchored but on iPhone X the result is that the gui go partially off to the edge of the screen.

I tried also with this sample project https://bitbucket.org/p12tic/iossafeareasplugin mentioned in the other post but that sample not is for NGUI. My problem is my app run on all Apple and Android devices, then I can't adjust the widget's offsets for iPhone X only because this will impact on all other devices.

So, definitively, there are solutions (in this case) with NGUI?
Many thanks.

Kafar

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: iPhone X display NGUI support
« Reply #1 on: February 20, 2018, 02:43:42 PM »
SOLVED.

krMeEjNzy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: iPhone X display NGUI support
« Reply #2 on: March 01, 2018, 08:41:49 AM »
Please could you share how did you solve this? It would be really helpful.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,151
  • Toronto, Canada
    • View Profile
Re: iPhone X display NGUI support
« Reply #3 on: March 29, 2018, 11:57:34 AM »
He asked in Discord. Just join Tasharen's discord (https://discord.gg/trruSNc) and scroll up in the #ngui-support channel to February 19th and you will see the conversation.

Quote
Kafar - 02/19/2018
I read NGUI support is moved here, so I put here my post:   Hello,

I read the only one post who talk about this topic (http://www.tasharen.com/forum/index.php?topic=15480.0) but it not is for me.
I have a UI Root and inside it many other UIpanels, UIButtons, etc, all anchored but on iPhone X the result is that the gui go partially off to the edge of the screen.

I tried also with this sample project https://bitbucket.org/p12tic/iossafeareasplugin mentioned in the other post but that sample not is for NGUI. My problem is my app run on all Apple and Android devices, then I can't adjust the widget's offsets for iPhone X only because this will impact on all other devices.

So, definitively, there are solutions (in this case) with NGUI?
Many thanks.
p12tic / iOSSafeAreasPlugin
A Unity project containing a native plugin wrapping iOS safe areas APIs
I forgot..... googling I can't found nothing about this
@Aren
Aren - 02/19/2018
https://answers.unity.com/questions/1432365/how-to-detect-iphone-x-or-ipad-using-iosdevicegene.html

@Kafar
if the device is not iphone x, disable that adjustment script of yours
Kafar - 02/19/2018
Thank @Aren but after I checked the device is a iPhone X I can  adjust UIpanels, UIWidgets, NGUI etc via code?
Aren - 02/19/2018
you should adjust the UICamera's camera's viewport
if you adjust that, you don't need to do anything
basically offset the viewport on the top by X pixels, where X is what's needed
Kafar - 02/19/2018
CORRECT!!!! MANY THANKS!
but.... viewport or Field of View?
I tried to offset the viewport but nothing change, with Field of View yes
Aren - 02/19/2018
Viewport Rect
Kafar - 02/19/2018
yes, Viewport Rect, I changed but nothing change
Viewport Rect accept negative values also?
Aren - 02/19/2018
yeah
if you have a sprite anchored across the entire screen, you will see it move when you adjust the viewport rect
simplest script for you is -- have the viewport rect be adjusted to what you need it to be for iphone x, then have your script simply set the rect to 0 and 1's if it's not iphone x
Kafar - 02/19/2018
ok, thanks!
Kafar - 02/19/2018
@Aren I'm sorry but I don't understand.... if I edit values for Viewport Rect X the GUI move to right or left but it not fit. Same thing if I edit Y or W or H. What is wrong?
Aren - 02/19/2018
try setting height to 0.97
there will be empty space on top equal to 0.03 * screen height pixels
Kafar - 02/19/2018
from code is Camera.ViewportToScreenPoint(Vector3)? If yes, the X, Y, W, H and specifically the H where I set it?
Aren - 02/19/2018
?
select the game object in inspector
set its camera script viewport rect
Kafar - 02/19/2018
no, I need to do in the script, in the case the app don't run on the iphonex
Aren - 02/19/2018
consult unity's documentation for how to set viewport rect via code, or look at the UIViewport script
Camera.rect