Author Topic: SetAnchor causes the y component to increase to infinity.  (Read 2314 times)

zippo227

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
SetAnchor causes the y component to increase to infinity.
« on: May 26, 2014, 12:37:03 AM »
I'm dynamically creating a label and anchoring it to an object that moves. I'm calling the UILabel.SetAnchor(myObj) function. For some objects, even if the object is standing in idle, assigning the object as the anchor causes the label to move upwards off the screen very quickly.

This didn't happen with my previous version of NGUI. I am on 3.6.0, and this has been happening for the last couple of versions.

zippo227

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
Re: SetAnchor causes the y component to increase to infinity.
« Reply #1 on: May 26, 2014, 08:20:40 PM »
I made an interesting class to solve this problem. Message me privately if you are interested in putting the solution into NGUI.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: SetAnchor causes the y component to increase to infinity.
« Reply #2 on: May 26, 2014, 11:51:29 PM »
How would I reproduce this on my end?

zippo227

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
Re: SetAnchor causes the y component to increase to infinity.
« Reply #3 on: May 27, 2014, 01:29:20 AM »
Essentially, anchor the UILabel to an animating character. That's what did it for me.

directedchaos

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: SetAnchor causes the y component to increase to infinity.
« Reply #4 on: January 21, 2015, 03:04:45 AM »
I just ran into this too, with a UISprite anchored in code to another UISprite's background whose size changes.  However, even when the size of the target doesn't change, it keeps shooting the transform's y to infinity.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: SetAnchor causes the y component to increase to infinity.
« Reply #5 on: January 22, 2015, 11:05:42 AM »
I can see this happening if you create a circular anchor: something anchored to a parent object that includes the child in its bounds, so basically something that effectively gets anchored to itself. I'll need an actual step by step guide or a repro case to examine this further as "anchor a label to an animating character" doesn't give me anything.

zippo227

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
Re: SetAnchor causes the y component to increase to infinity.
« Reply #6 on: January 28, 2015, 01:13:21 AM »
I fixed the problem with an interesting workaround, so I don't have anything to send you. I'm sure you are right in that it is some kind of circular dependency. Hopefully the other commenter has a fresh project that can be sent to you!