Author Topic: UIAnchor bug  (Read 3373 times)

gamesmith

  • Guest
UIAnchor bug
« on: May 11, 2012, 01:04:38 AM »
I've got a fairly complex UI setup for a game with multiple UIAnchors (some with the same positions set -- to help divide up the UI). When my game loads on the iPhone the lower left anchor starts out in the wrong position, hangs there while the level loads and then shifts into position.

It is sometimes possible to recreate the bug in the editor by expanding and contracting the viewport (by resizing the window). The "sticking" part isn't noticeable in the editor during normal testing -- most likely because it's being corrected too fast to see it.

I've also noticed the bug will go away if I deactivate/reactivate the anchor. It comes back after a test cycle however.

This only seems to effect the Lower Left anchor. Has anyone else seen this? Is there a known fix?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIAnchor bug
« Reply #1 on: May 11, 2012, 01:52:34 AM »
UIAnchor updates itself in Update(). If it doesn't receive an Update call, it won't reposition itself. My guess is, there are no updates during level load. Either that, or you didn't specify a camera for the anchor to work with.

gamesmith

  • Guest
Re: UIAnchor bug
« Reply #2 on: May 11, 2012, 07:38:51 AM »
The camera is set correctly.

The thing is it shouldn't have to reposition itself because it's in the correct position to start with. When the scene loads it's ~100px "north" of its correct position. It hangs there for a moment and then "drops" into place.

All other anchors start out in the correct position.

I'm pretty sure this started happening after I updated to 2.0.4c.

[Edit:]

It's easily reproducible for me (using the most recent Unity and OS X Lion) by resizing the window and then pressing Command-S to save. I'm pretty sure saving the scene calls Update().

If I save one time the Bottom Left AND Top Right anchors are in the wrong positions. They seem to be off by equal and opposite amounts and the amounts seem to correlate to their previous position. Pressing Command-S twice moves them to their correct positions.
« Last Edit: May 11, 2012, 07:54:42 AM by gamesmith »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIAnchor bug
« Reply #3 on: May 11, 2012, 02:41:00 PM »
When you resize a game window in Unity, none of the scene objects are sent Update calls. When you save the scene, or click on the game window, an Update is sent, thus allowing widgets to reposition.