For example, we can specify which script functions to called for OnClick event for UI button, but in the “Select Object” field, I can only specify the object which is already in the scene, or a prefab. What if I want to pass the UI event to a specific instance of the game object which only get created in runtime? Thanks!
For example if you have a Runtime button . Button b;
void abababa()
{
///// b is instantiated
b.onClick.AddListener(delegate() {
ButtonClicked(b);
}
);
}
public void ButtonClicked(Button bd)
{
Debug.LogError(bd.name);
}
//// you can pass any other or no parameter too . I dont know about its limit. may be four. If you want to pass a GameObject change parameter type Button to GameObject and pass that game object in ButtonClicked(b);