Last time there was no problem to use EventDelegate
but today I don't know why EventDelegate.parameters[0] returns null reference exception.
The code with problem is this.
void OnEnable() {
removeAllList();
Group[] searchedGroups = controller.groupStore.searchedGroups;
int length = searchedGroups.Length;
if(length == 0) {
emptyMessage.SetActive(true);
return;
}
for(int i=0; i<length; i++) {
GameObject item = Instantiate(container);
item.transform.SetParent(grid.transform);
item.transform.localPosition = Vector3.zero;
item.transform.localScale = Vector3.one;
item.GetComponent<GroupIndex>().id = searchedGroups.id;
item.transform.Find("LocationLabel").GetComponent<UILabel>().text = searchedGroups.locationDistrict + " " + searchedGroups.locationCity;
item.transform.Find("GroupNameLabel").GetComponent<UILabel>().text = searchedGroups.name;
item.transform.Find("MemberCountLabel").GetComponent<UILabel>().text = "멤버 " + searchedGroups.membersCount + "명";
EventDelegate addEvent = new EventDelegate(this, "addEvent_test");
EventDelegate.Parameter param = new EventDelegate.Parameter();
param.obj = item;
param.field = "Index";
addEvent.parameters[0] = param;
GameObject tmp = item.transform.Find("GotoDetailBtn").gameObject;
EventDelegate.Add(tmp.GetComponent<UIButton>().onClick, addEvent);
}
}
public void addEvent_test() {
}
please anyone could help me. thanks.