Author Topic: Bug in UIAnchor  (Read 2172 times)

Amitloaf

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
    • View Profile
Bug in UIAnchor
« on: January 29, 2014, 09:12:08 AM »
One of them is easy for me to reproduce. The other.. is not.
Let's start with the first:
1) I have a UIPanel with a horizontal stretch. Under it, there's a child with a UIGrid and an Anchor to the left (to make it snap to the left side on creation so it will always be anchored to the left, no matter the resolution) but because the panel father is also a UIScrollView, I made it so the Anchor is set to Run Only Once.
In theory it should work as it will snap the anchor in the beginning and every screenchange. In practice it doesn't. I can see by debugging that it does actually calls update but it doesn't step. Moreover, if I turn the anchor on and then off again manually, it does snap. So I guess it's a bug in the Run Once Only. Maybe it does the calculations before the screen parameters it works by actually change.
To work around it, whenever I change screensize or something I just enable the anchor and it disables it by itself on Update and it fixes it.

Cripple

  • TNP Alpha
  • Full Member
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Bug in UIAnchor
« Reply #1 on: January 29, 2014, 09:15:49 AM »
UIAnchor is deprecated, you have to use the last anchoring system :

http://www.youtube.com/watch?v=6k5iIzKTEBQ&list=UUQGZdUwzE8gmvgjomZSNFJg&feature=c4-overview
Graphicstream Dev.

Amitloaf

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: Bug in UIAnchor
« Reply #2 on: January 29, 2014, 10:59:19 AM »
Ok but UIGrid doesn't have the new anchor, so how do I keep it anchored?

Cripple

  • TNP Alpha
  • Full Member
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Bug in UIAnchor
« Reply #3 on: January 29, 2014, 11:02:45 AM »
You have to add an UIWidget to your gameObject. UIGrid is not a widget, it is more like an helper that places children gameobject.
Graphicstream Dev.

Amitloaf

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: Bug in UIAnchor
« Reply #4 on: January 29, 2014, 12:31:45 PM »
Oh thanks!
I didn't know I can't just add a "UIWidget" script to whatever. I thought you needed to actually have a widget there. Thanks.
« Last Edit: January 30, 2014, 04:15:13 AM by Amitloaf »