public void OnCameraOpened()
 {
     PositionDropdown.value = (int)Camera.DevicePosition;
     if (Camera.IsFocusModeSupported(CaptureFocusMode.AutoFocus))
     {
         FocusModeLayout.SetActive(true);
         FocusModeDropdown.value = (int)Camera.FocusMode;
     }
     else
     {
         FocusModeLayout.SetActive(false);
     }
     if (Application.platform == RuntimePlatform.IPhonePlayer && Camera.IsAutoFocusRestrictionSupported)
     {
         AutoFocusRestrictionLayout.SetActive(true);
         AutoFocusRestrictionDropdown.value = (int)Camera.AutoFocusRestriction;
     }
     else
     {
         AutoFocusRestrictionLayout.SetActive(false);
     }
     if (Camera.IsFlashModeSupported(CaptureFlashMode.On))
     {
         FlashModeLayout.SetActive(true);
         FlashModeDropdown.value = (int)Camera.FlashMode;
     }
     else
     {
         FlashModeLayout.SetActive(false);
     }
     if (Mathf.Approximately(Camera.MaxZoomLevel, 1.0f))
     {
         ZoomLayout.SetActive(false);
     }
     else
     {
         ZoomLayout.SetActive(true);
         ZoomScrollbar.value = (Camera.ZoomLevel - 1.0f) / (Camera.MaxZoomLevel - 1.0f);
     }
     if (Camera.FocusMode == CaptureFocusMode.Locked && Camera.IsFocusModeSupported(CaptureFocusMode.Locked) && Camera.IsManualFocusAvailable)
     {
         ManualFocusLayout.SetActive(true);
     }
     else
     {
         ManualFocusLayout.SetActive(false);
     }
 }
Beispiel #2
0
    public void OnCameraOpened()
    {
        /* After the camera was opened, check what capabilities it has, to make sure that only the appropriate controls are displayed. */

        /* When checking if a certain camera feature is supported, the SDK will report an error if it is not, indicating the reason.
         * Since we are not interested in the reason, we temporarily suppress error handling until the end of the method.
         */
        _suppressErrors = true;
        if (_cameraListSupported)
        {
            PositionDropdown.value = Camera.GetActiveCameraIndex();
        }
        else
        {
            PositionDropdown.value = (int)Camera.DevicePosition;
        }

        if (Camera.IsFocusModeSupported(CaptureFocusMode.AutoFocus))
        {
            FocusModeLayout.SetActive(true);
            FocusModeDropdown.value = (int)Camera.FocusMode;
        }
        else
        {
            FocusModeLayout.SetActive(false);
        }
        /* AutoFocusRestriction is only available on iOS, so disable the controls for other platforms. */
        if (Application.platform == RuntimePlatform.IPhonePlayer && Camera.IsAutoFocusRestrictionSupported)
        {
            AutoFocusRestrictionLayout.SetActive(true);
            AutoFocusRestrictionDropdown.value = (int)Camera.AutoFocusRestriction;
        }
        else
        {
            AutoFocusRestrictionLayout.SetActive(false);
        }

        if (Camera.IsFlashModeSupported(CaptureFlashMode.On))
        {
            FlashModeLayout.SetActive(true);
            FlashModeDropdown.value = (int)Camera.FlashMode;
        }
        else
        {
            FlashModeLayout.SetActive(false);
        }

        if (Mathf.Approximately(Camera.MaxZoomLevel, 1.0f))
        {
            /* If the maximum zoom level is 1 or close to 1, the camera doesn't support zooming. */
            ZoomLayout.SetActive(false);
        }
        else
        {
            ZoomLayout.SetActive(true);
            ZoomScrollbar.value = (Camera.ZoomLevel - 1.0f) / (Camera.MaxZoomLevel - 1.0f);
        }

        /* Manual focus in only available when the FocusMode is set to Locked. Otherwise the control is disabled. */
        if (Camera.FocusMode == CaptureFocusMode.Locked && Camera.IsFocusModeSupported(CaptureFocusMode.Locked) && Camera.IsManualFocusAvailable)
        {
            ManualFocusLayout.SetActive(true);
        }
        else
        {
            ManualFocusLayout.SetActive(false);
        }

        StartCoroutine(EnableErrors());
    }