alvyxaz / barebones-masterserver

Master Server framework for Unity
475 stars 106 forks source link

[Update request] Add 1 line if code in Barebones.Utils.GenericUIList #129

Open An147 opened 7 years ago

An147 commented 7 years ago

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

An147 commented 7 years ago

Sorry, I think there is also a need to instantiate prefab