1 Reply
      Latest reply on May 28, 2018 1:44 AM by manutd100
      Skote Level 1 Level 1 (0 points)

        Hi,

         

        I'm working on a small augmented reality experience for a museum using Unity and ARkit 1.5. In some locations the light is very low so for ARkit to be able to see the markers I need to turn on the torch. I haven't found any tool for doing this within Unity so I guess I need to do it in Xcode. Does anyone have experience of this and can point me in the right direction?

         

        Cheers

        • Re: Using the Torch while using ARkit?
          manutd100 Level 1 Level 1 (0 points)

          if let device = AVCaptureDevice.default(for: .video), let input = try? AVCaptureDeviceInput.init(device: device),

                      device.hasFlash, device.hasTorch {

                      var torch = input.device.torchMode

                    

                      switch torch {

                      case .off:

                          torch = .on

                          sender.setBackgroundImage( imageLiteral(resourceName: "torch_off"), for: UIControlState.normal)

                      case .on:

                          torch = .off

                          sender.setBackgroundImage( imageLiteral(resourceName: "torch_on"), for: UIControlState.normal)

                      default:

                          break

                      }

                    

                      try? input.device.lockForConfiguration()

                      input.device.torchMode = torch

                      input.device.unlockForConfiguration()

                  }