public void ReleaseUsage(ICameraImageRequester requester) { if (requester == _currentRequester) { _currentState.Value = State.STOPPING_PHOTO_MODE; } }
public LocatableCameraController() { _keywordRecognizer = new KeywordRecognizer(_keywords); _keywordRecognizer.OnPhraseRecognized += OnPhraseRecognized; _keywordRecognizer.Start(); _currentState = new ReactiveProperty <State>(State.NOT_IN_USE); _currentState.ObserveOn(Scheduler.MainThread).SubscribeOn(Scheduler.MainThread).Subscribe(state => { if (state == State.NOT_IN_USE) { _currentRequester = null; } else if (state == State.STARTING_PHOTO_MODE) { _photoCaptureObject.StartPhotoModeAsync(_cameraParameters, OnPhotoModeStarted); } else if (state == State.TAKING_PHOTO) { _photoCaptureObject.TakePhotoAsync(OnPhotoCapturedToMemory); } else if (state == State.STOPPING_PHOTO_MODE) { _photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode); } }); #if !UNITY_EDITOR PhotoCapture.CreateAsync(false, OnPhotoCaptureCreated); #endif }
private void OnStoppedPhotoMode(PhotoCapture.PhotoCaptureResult result) { if (result.success) { _currentRequester = null; _currentState.Value = State.NOT_IN_USE; } else { Debug.LogError("Unexpected error when stopping photo mode"); _currentRequester = null; _currentState.Value = State.NOT_IN_USE; } }
public bool RequestUsage(ICameraImageRequester requester) { if (_currentState.Value == State.NOT_IN_USE && _currentRequester == null) { _currentRequester = requester; _currentState.Value = State.STARTING_PHOTO_MODE; return(true); } else if (_currentState.Value == State.ERROR_STARTING_PHOTO_MODE && requester == _currentRequester) { _currentState.Value = State.STARTING_PHOTO_MODE; return(true); } else { return(false); } }