Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

NatDevice - Media Device API

Discussion in 'Assets and Asset Store' started by Lanre, Dec 17, 2015.

?

Should we add exposure controls in v1.3? This means dropping support for iOS 7

Poll closed Jun 10, 2016.
  1. Yes

    9 vote(s)
    75.0%
  2. No

    3 vote(s)
    25.0%
  1. FreedLOW

    FreedLOW

    Joined:
    Dec 7, 2019
    Posts:
    11
    @Lanre Hi, I work on AR app with AR Foundation and use following code, but it's not working on any device, maybe I miss something?

    Code (CSharp):
    1.  
    2. query = new MediaDeviceQuery(MediaDeviceCriteria.CameraDevice);
    3. cameraDevice = query?.current as CameraDevice;
    4.  
    5. private void ControlFlashLight()
    6.         {
    7.             if (!cameraDevice.flashSupported) return;
    8.        
    9.             if (cameraDevice.flashMode == CameraDevice.FlashMode.On)
    10.             {
    11.                 cameraDevice.flashMode = CameraDevice.FlashMode.Off;
    12.                 flashImage.DOColor(Color.gray, 1f);
    13.             }
    14.             else
    15.             {
    16.                 cameraDevice.flashMode = CameraDevice.FlashMode.On;
    17.                 flashImage.DOColor(Color.white, 1f);
    18.             }
    19.         }
    or I use thic code to toggle flash on phone but it's with error:
    Error NatML CameraDevice 0 failed to set torch mode

    Code (CSharp):
    1. if (isFlashOn)
    2.             {
    3.                 cameraDevice.torchEnabled = false;
    4.                 flashImage.DOColor(Color.gray, 1f);
    5.             }
    6.             else
    7.             {
    8.                 cameraDevice.torchEnabled = true;
    9.                 flashImage.DOColor(Color.white, 1f);
    10.             }
     
    Last edited: Jun 29, 2023
  2. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,960
    Hey there. If your camera device is running with ARFoundation, then you can't use NatDevice to interact with the camera at all (camera devices can only be used exclusively).
     
    FreedLOW likes this.