Author Topic: iOS status bar  (Read 2213 times)

hrlarsen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 35
    • View Profile
iOS status bar
« on: February 19, 2014, 03:54:58 AM »
Hi everyone

I wonder if any of you have had any experience in dealing with the status bar on iOS. I want my application to show the status bar on iOS, but Unity (unfortunately) does not seem to reduce the rendering window size when the status bar is present, it just renders on top.

I know that for NGUI I can simply make a nested UIPanel, where I set the top anchor X pixels lower when on iOS, but this do not apply to the rendering of the non NGUI stuff.

The problem do not apply when on Android

Best
/ hrlarsen

hrlarsen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 35
    • View Profile
Re: iOS status bar
« Reply #1 on: February 19, 2014, 09:26:39 AM »
My best approach so far, though not without errors, is to set the camera.rect = new Rect(0f, -0.05f, 1.05f, 1f);

However, this raise the problem that NGUI's new anchoring system do not work, because it do not account for the new width of the cameras rect. Is there anyway to work around this?

I've attached a picture, which hopefully explains the issue

EDIT: I found that this is happening only if any clipping is present on the panel, or if Offset is checked
« Last Edit: February 19, 2014, 09:42:11 AM by hrlarsen »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: iOS status bar
« Reply #2 on: February 19, 2014, 03:32:04 PM »
Camera rect is supposed to have coordinates in 0 to 1 range, and you seem to be going outside that. NGUI's UIRoot scales itself based on Screen.height, and it knows nothing about which camera is used to draw it, so it doesn't take its rect into consideration. If you want it to do that, set the UIRoot to Manual, and then set its height based on the camera's view rect.

hrlarsen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 35
    • View Profile
Re: iOS status bar
« Reply #3 on: February 19, 2014, 04:35:31 PM »
I have my root at a fixed height but your answer helped med figure out a work around.

I change the line 154 of UIRoot to: mTrans.localScale = new Vector3(size * (1f + Mathf.Abs(Camera.main.rect.y)), size, size)
Assuming that the camera used to render NGUI is the main camera (I have a GUI only app)

This allows me to only change the y of the cameras rect to -0.04f which I find to be good making sure that the status bar is free.
« Last Edit: February 19, 2014, 04:48:20 PM by hrlarsen »