Author Topic: updating from 3.5.4 to 3.5.8 broke anchoring through code  (Read 1255 times)

genesys

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
updating from 3.5.4 to 3.5.8 broke anchoring through code
« on: April 23, 2014, 09:43:26 AM »
I just upgraded our project from NGUI 3.5.4 to 3.5.8 through the asset store and now all of our menu screens are broken. They get anchored to UIRoot through code right after instanciating them with NGUITools, so they assume the size of the screen (minus some small, constant border). This worked well on 3.5.4 but now for some reason now the windows do not update when the UIRoot and Anchor values are set through code. If I change one of the Anchor values throug the editor while the game is running, the Widgets immediately pop to their correct size.

Is it necessary to call something now after setting Anchor parameters through code?

here's a screenshot of the inspector of the window, after it got instanciated. For some reasons it's only 2x2pixels in size (after changing one of the anchor values through code, the size changes to the expected size):

//edit: calling _widget.UpdateAnchors(); after setting the anchors through code does not solve the problem
« Last Edit: April 23, 2014, 10:54:23 AM by genesys »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: updating from 3.5.4 to 3.5.8 broke anchoring through code
« Reply #1 on: April 24, 2014, 12:31:23 AM »
You need to call both ResetAnchors() and UpdateAnchors(). Check how SetAnchor() function works and what it does inside.