zastrow
1
for (int x = 0; x < xList.Count; x++ )
{
myY -= 30;
Button newUser = Instantiate(listButton) as Button;
txtUsername.text = gameArray[x, 1];
newUser.transform.parent = listPanel.transform;
newUser.rectTransform.anchoredPosition = new Vector2(0, myY);
}
This works great with UI.Text elements. Why wouldn’t this work for all UI elements?
How else am I going to set the anchoredPosition?
zastrow
2
Nevermind, I figured it out. You kinda have to do a kabooki dance with RectTransform.
for (int x = 0; x < xList.Count; x++ )
{
myY -= 30;
Button newUser = Instantiate(listButton) as Button;
txtUsername.text = gameArray[x, 1];
newUser.transform.parent = listPanel.transform;
RectTransform transform = newUser.gameObject.transform as RectTransform;
Vector2 position = transform.anchoredPosition;
transform.anchoredPosition = new Vector2(0, myY);
}