Although it's possible to set the
Pivot to 'Top Right', I'm wondering if there's a way to force a UIGrid to organize the items from right to left, rather than left to right. Using alphabetical ordering and adjusting names of the children accordingly won't work; that merely reorganizes the children, left to right, but with the children in the opposite order. What I am trying to accomplish is a row of health icons attached to the right side of the screen, limited to 6 per column. The problem is, the new column starts at the left end of the new row.
Besides my problems with left to right, I'm having some anomalous behavior where the 6th icon on the second row decides to start it's own new row. I'm not manually adjusting anything, I'm leaving everything up to the UIGrid component, so I'm not sure what's causing it. Below is the entire code that interfaces with the UIGrid, I add and remove icons by enabling or disabling their UISprite to make them invisible. I am renaming them so that Alphabetic sorting will organize them according to their index in the list of UISprites to show/hide; however, this causes even more unusual behavior including random gaps in the rows.
public void CreateIcons (int current, int maximum)
{
grid = GetComponent<UIGrid>();
for (int i = 0; i < maximum; i++)
{
GameObject newIcon = NGUITools.AddChild(transform.gameObject, armorIcon);
icons.Add(newIcon.GetComponent<UISprite>());
newIcon.name = i.ToString();
grid.AddChild(newIcon.transform);
}
DisplayIcons(current);
}
Edit: I believe I've solved the problem with mysterious alphabetical sorting order; there are twelve icons. 10 comes after 1. The sorting is strictly alphabetical, not lexicographical. I'll need to prefix extra 0's before single digit numbers.