I'm currently populating a table with a prefabs created through simple code like this:
Elev[] students = DatabaseManagement.Instance.GetStudentsInRoom(references.Id);
for (int i = 0; i < students.Length; i++)
{
PoolManager.Instance.CreateNameTagPrefab(students[i], InfoPanelTable);
}
StartCoroutine(DelayedReposition());
The method CreateNameTagPrefab instantiates a prefab using NGUITools.AddChild and adds it to the table. The prefab's labels are all updated with the values of the given student.
The coroutine consist of this:
yield return null;
InfoPanelTable.GetComponent<UITable>().Reposition();
InfoPanelTable.transform.parent.GetComponent<UIScrollView>().ResetPosition();
The problem is that I have to delay the reposition by one frame in order to wait for anchors to update in the name prefab.
The ingame view looks like
this.
This picture is an example of how it looks like with minimal info, but if the note is longer it will stretch a bit and look like
this - so far, nothing is wrong.
The problem is that since it waits one frame it will flicker a bit:
http://i.imgur.com/1GqZzNW.gif (primarily text overlapping due it them all being created in one place).
If I remove the frame delay it will reposition it to the original prefab size (before the anchors have been recalculated) and look like
this (I'm not really sure why it goes all wonky either...)
Is there any way to force anchors to update instead of having to wait a frame?