Hi I need to set anchor just on left and right with value 0, and on bottom and top to null, all this in code but I don't know how to setup correctly.
I check UIRect.SetAnchor() but this set the anchor of type unified, how can I set it on advance?
Also I'm using this code:
for(int i = 0; i<= 10; i++)
{
GameObject row = NGUITools.AddChild(Grid, prefabRow);
row.GetComponent<UISprite>().leftAnchor.target = ScrollView.transform;
row.GetComponent<UISprite>().leftAnchor.absolute = 0;
row.GetComponent<UISprite>().rightAnchor.target = ScrollView.transform;
row.GetComponent<UISprite>().rightAnchor.absolute = 0;
row.GetComponent<UISprite>().ResetAnchors(); /////////////The line that was missing to work correctly
}
Grid.getComponent<UIGrid>().Reposition();
ScrollView.ResetPosition();
And this correctly set the anchor, the problem that I have with the last one is when I instantiate a new row tje width of the sprite is set to small like 2 pixels. But if I disable the gameObject (row) and enable it again the anchor updates the sprite width correctly, something that didn't happen on previous version of ngui, but now happens when I update to last version.
SOLUTION
I need to call ResetAnchors() before I set the anchors