Подскажите, как, имея имя метода, добавить на кнопку в OnClick. У меня он либо игнорирует(как в данном случае) и ничего не происходит при нажатие, или выскакивает ошибка
Синтаксис:
Используется csharp
for (int i = 0; i < buttons.Count; i++)
{
if (buttons[i] != null) buttons[i].GetComponent<Button>().onClick.AddListener(() => this.GetComponent<ButtonsLogic>().GetType().GetMethod("DeviceOnOff").CreateDelegate(typeof(UnityAction), this.GetComponent<ButtonsLogic>()));
}
{
if (buttons[i] != null) buttons[i].GetComponent<Button>().onClick.AddListener(() => this.GetComponent<ButtonsLogic>().GetType().GetMethod("DeviceOnOff").CreateDelegate(typeof(UnityAction), this.GetComponent<ButtonsLogic>()));
}