Based on Example 7 (Scroll view panel) I added 3 checkboxes dynamically to a grid.
I had set a layer to the Grid's parent panel, and according to my game state I add/remove this layer from camera.cullingMask and camera.eventReceiverMask.
Once the player had checked some of the checkboxes and submit - the panel is not rendered (and the checkboxes are still checked).
Next time the panel should be rendered (with the appropriate game state) I reset the checkboxes to be unchecked with the following code:
foreach (Transform child in grid)
{
UICheckbox cb = child.GetComponent<UICheckbox>();
cb.isChecked = false;
}
This reset cause the grid to respond incorrectly when I click a checkbox immediately after the reset. Though the checkbox hover works correctly, after the click it is still unchecked.
I found out that if I wait ~3 seconds after this reset - then chicking a checkbox works fine.
In several places I tried to use
grid.GetComponent<UIGrid>().Reposition() ,
grid.parent.GetComponent<UIPanel>().Refresh() ,
grid.parent.GetComponent<UIDraggablePanel>().ResetPosition()
but couldn't solve this issue.
What am I missing?