public void AddDevicesButtons(string name, string uuid) { if (interfaceType == AndroidInterface.None) { return; } GameObject deviceBtn = GameObject.Instantiate(getDeviceButtonPrefab(), getPanel()); deviceBtn.transform.name = uuid; deviceBtn.transform.Find("DeviceName").transform.GetComponent <Text>().text = name; Button btn = deviceBtn.GetComponent <Button>(); BLEDeviceButton_Interface deviceInterface = new BLEDeviceButton_Interface(btn); devicesButtons.Add(name, deviceInterface); // Add connect event btn.onClick.AddListener(() => bleCommunication.ConnectPeripheral(uuid, name)); // Add disconnect event deviceInterface.disconnect.GetComponent <Button>().onClick.AddListener(() => this.DisconnectDevice()); }