Please, update this abstract helping class. The issue is that your code is working only for particular case when UIGameListItem prefab is an existing object in scene that have LayoutGroup as parent object (like in your demos).
I tried to make things work when I had empty LayoutGroup and prefab was situated in folder, hence it hadn't any parent Transform. I spend about an hour to realize what is going on!
public GenericUIList(GameObject prefab, LayoutGroup list){_prefab = prefab;_list = list;_items = new List<GameObject> {prefab};// Disable a prefabprefab.SetActive(false);}
Here in constructor you just set prefab inactive. Please just add one line:
prefab.transform.parent = list.transform;
Hello.
Please, update this abstract helping class. The issue is that your code is working only for particular case when UIGameListItem prefab is an existing object in scene that have LayoutGroup as parent object (like in your demos).
I tried to make things work when I had empty LayoutGroup and prefab was situated in folder, hence it hadn't any parent Transform. I spend about an hour to realize what is going on!
public GenericUIList(GameObject prefab, LayoutGroup list)
{
_prefab = prefab;
_list = list;
_items = new List<GameObject> {prefab};
// Disable a prefab
prefab.SetActive(false);
}
Here in constructor you just set prefab inactive. Please just add one line:
prefab.transform.parent = list.transform;
Regards, Andrey