/** * Populates the list of casts with devices, and sets up callbacks for selecting said devices. */ public void PopulateList(CastRemoteDisplayManager manager) { foreach (var button in currentButtons) { Destroy(button); } currentButtons.Clear(); IList <CastDevice> devices = manager.GetCastDevices(); foreach (CastDevice listDevice in devices) { GameObject newButton = Instantiate(listElementPrefab) as GameObject; CastListButton button = newButton.GetComponent <CastListButton>(); button.nameLabel.text = listDevice.DeviceName; button.statusLabel.text = listDevice.Status; string deviceId = listDevice.DeviceId; button.button.onClick.AddListener(() => { manager.SelectCastDevice(deviceId); castButtonFrame.ShowConnecting(); this.ShowConnectingState(); }); newButton.transform.SetParent(contentPanel.transform, false); currentButtons.Add(newButton); } if (!connecting) { ResetDialog(); } }
private void TryConnectCast() { if (castDevices.Count > 0 && !castDisplayManager.IsCasting()) { CastDevice device = castDevices[0]; castDisplayManager.SelectCastDevice(device.DeviceId); } }
/** * Populates the list of casts with devices, and sets up callbacks for selecting said devices. */ public void PopulateList(CastRemoteDisplayManager manager) { foreach (var button in currentButtons) { Destroy(button); } currentButtons.Clear(); IList<CastDevice> devices = manager.GetCastDevices(); foreach (CastDevice listDevice in devices) { GameObject newButton = Instantiate(listElementPrefab) as GameObject; CastListButton button = newButton.GetComponent<CastListButton>(); button.nameLabel.text = listDevice.DeviceName; button.statusLabel.text = listDevice.Status; string deviceId = listDevice.DeviceId; button.button.onClick.AddListener(() => { manager.SelectCastDevice(deviceId); castButtonFrame.ShowConnecting(); this.ShowConnectingState(); }); newButton.transform.SetParent(contentPanel.transform, false); currentButtons.Add(newButton); } if (!connecting) { ResetDialog(); } }