Hi, I am seeing a problem when instantiating rows in the UI whereby I have to click twice on the shopkeeper for the items to appear. On the first click, the child objects are destroyed and the list appears empty. The ‘content’ gameobject in the hierarchy is also empty. Then (regardless of whether I leave the UI open or close it) after the second click on either of my two shopkeepers, the behaviour is as expected.
private void RefreshUI()
{
foreach (Transform child in listRoot)
{
Destroy(child.gameObject);
}
Debug.Log(currentShop.GetShopName());
foreach (ShopItem shopItem in currentShop.GetFilteredItems())
{
RowUI newRow = Instantiate<RowUI>(rowPrefab, listRoot);
Debug.Log(newRow.name);
}
}
Note the Debug.Log line I added to check if the instantiation was creating a genuine object. This correctly logged out “Row (clone)” for all 3 new rows on both the first and second click.