#if UNITY_IOS using System.Runtime.InteropServices; using UnityEngine; /// /// Class to interact with flashlight /// [PublicAPI] public static class IGFlashlight { /// /// Indicates whether current device has a flashlight /// /// true if current device has a flashlight, false otherwise [PublicAPI] public static bool HasTorch { get { if (IGUtils.IsIosCheck()) { return false; } return _DeviceHasFlashlight(); } } /// /// Toggle the flashlight /// /// Whether to enable or disable the flashlight [PublicAPI] public static void EnableFlashlight(bool enable) { if (IGUtils.IsIosCheck()) { return; } _EnableFlashlight(enable); } /// /// Enables flashlight with the provided intensity /// /// Intensity of the flashlight to set. Clamped between 0 and 1 [PublicAPI] public static void SetFlashlightIntensity(float intensity) { intensity = Mathf.Clamp01(intensity); if (IGUtils.IsIosCheck()) { return; } _SetFlashlightLevel(intensity); } [DllImport("__Internal")] static extern void _EnableFlashlight(bool enable); [DllImport("__Internal")] static extern void _SetFlashlightLevel(float val); [DllImport("__Internal")] static extern bool _DeviceHasFlashlight(); } #endif