private void Start() { var currentDevice = 0; var button = GetComponent <Button>(); button.OnClickAsObservable() .Select(_ => currentDevice < WebCam.Devices.Length ? currentDevice++ : 0) .Subscribe(x => WebCam.ChangeWebCam(WebCam.Devices[x])) .AddTo(this); }
private void Start() { var dropdown = GetComponent<Dropdown>(); var deviceNames = WebCam.Devices.Select(x => x.name).ToList(); dropdown.AddOptions(deviceNames); dropdown.RefreshShownValue(); dropdown.OnValueChangedAsObservable() .Subscribe(x => WebCam.ChangeWebCam(WebCam.Devices[x])) .AddTo(this); }