Author Topic: UICamera Lateupdate change  (Read 2602 times)

jlloyd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
UICamera Lateupdate change
« on: September 07, 2016, 08:08:50 PM »
Hello again,

We are trying out a change to UICamer Lateupdate.  We want to move the UIRoot.Broadcast("UpdateAnchors"); statement to after the onScreenResize(); call (line 1736ish).

This is changing the order of onScreenResize and UpdateAnchors. Previously, it called UpdateAnchors first then call onScreenResize. This could cause a problem if there are some UI Widget is using an UISretch object as anchors' target.

Usually onScreenResize won't be called on mobile devices except one situation: lock the android device when game running (I was using Sony Z1) and unlock it, you will receive two on ScreenResize call which the first one report change with portrait screen size then the second one with landscape screen size.

Do you see any issues with this change?

Thanks

Jobe

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera Lateupdate change
« Reply #1 on: September 09, 2016, 02:33:17 PM »
Why do you need to move the order of these two calls? NGUI only uses onScreenResize in two scripts, both legacy -- UIAnchor and UIStretch. Neither of these components should be used at this point. They're there for backwards compatibility only.

Vicky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UICamera Lateupdate change
« Reply #2 on: September 12, 2016, 12:38:18 PM »
It was because we didn't find another way to have a sprite extended width to match the width of the screen width other than using an UIStreth object as anchor target.

Do you have suggestion or example on what we can do for that requirement?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera Lateupdate change
« Reply #3 on: September 13, 2016, 11:13:33 AM »
All widgets have built-in anchoring. To stretch a sprite, anchor its left and right points to the camera.

Vicky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UICamera Lateupdate change
« Reply #4 on: September 13, 2016, 02:06:11 PM »
Most of menu resources in out game were saved and used as prefabs. We create objects dynamically in game from those prefabs when we need to use them.

In this case, we have to manually assign the anchor targets every time when we create the object because the UICamera won't be packed in the prefab. And we might have multiply game object need to use UICamera as anchor. To simplify that operation, it's better create one game object which has the anchoring and everything else use it as reference. So we only need to assign UICamera to that one object.

Then this object has no different than UIStretch except we have to manually to setup UICamera for it.

As we still have UIStretch available I don't see why the way than another.

Can we just keep using UIStretch? With the suggest fixing mentioned in origin post?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera Lateupdate change
« Reply #5 on: September 17, 2016, 12:19:15 AM »
If it works for what you're using, sure. Keep in mind though, you don't need to anchor to the camera. Anchoring to the panel has the same effect.