/** * 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(); } }
public new void Start() { base.Start(); castSearchAnimation = Instantiate(Resources.Load("Menu/CastSearchAnimation", typeof(GameObject))) as GameObject; Debug.Assert(castSearchAnimation != null); castSearchAnimation.transform.localPosition = new Vector3(0, 0.25f, 6); // Setup the castManager. this.castDisplayManager = CastRemoteDisplayManager.GetInstance(); castDisplayManager.RemoteDisplaySessionStartEvent.AddListener(OnRemoteDisplaySessionStart); castDisplayManager.RemoteDisplaySessionEndEvent.AddListener(OnRemoteDisplaySessionEnd); castDisplayManager.RemoteDisplayErrorEvent.AddListener(OnRemoteDisplayError); castDisplayManager.CastDevicesUpdatedEvent.AddListener(OnCastDevicesUpdated); this.castDevices = castDisplayManager.GetCastDevices(); InvokeRepeating("TryConnectCast", castConnectDelay, castConnectRepeat); }
public new void Start() { base.Start(); castSearchAnimation = Instantiate(Resources.Load("Menu/CastSearchAnimation", typeof(GameObject))) as GameObject; Debug.Assert(castSearchAnimation != null); castSearchAnimation.transform.localPosition = new Vector3(0, 0.25f, 6); // Setup the castManager. this.castDisplayManager = CastRemoteDisplayManager.GetInstance(); castDisplayManager.RemoteDisplaySessionStartEvent.AddListener(OnRemoteDisplaySessionStart); castDisplayManager.RemoteDisplaySessionEndEvent .AddListener(OnRemoteDisplaySessionEnd); castDisplayManager.RemoteDisplayErrorEvent .AddListener(OnRemoteDisplayError); castDisplayManager.CastDevicesUpdatedEvent .AddListener(OnCastDevicesUpdated); this.castDevices = castDisplayManager.GetCastDevices(); InvokeRepeating("TryConnectCast", castConnectDelay, castConnectRepeat); }
public void OnCastDevicesUpdated(CastRemoteDisplayManager manager) { this.castDevices = manager.GetCastDevices(); }
/** * 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(); } }