private static async void EnableFlashlightAsync(WSANativeColour colour = null) { string selectorString = Lamp.GetDeviceSelector(); DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selectorString); DeviceInformation deviceInfo = devices.FirstOrDefault(di => di.EnclosureLocation != null && di.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back); if (deviceInfo != null) { _lamp = await Lamp.FromIdAsync(deviceInfo.Id); if (_lamp.IsColorSettable && colour != null) { _lamp.Color = Windows.UI.Color.FromArgb(255, colour.Red, colour.Green, colour.Blue); } _lamp.IsEnabled = true; } }
/// <summary> /// Turns on the flashlight if the device supports it and optionally allows setting of the colour /// </summary> /// <param name="colour">Set the colour of the flashlight - does nothing if the device doesn't support it</param> public static void EnableFlashlight(WSANativeColour colour = null) { #if (NETFX_CORE && UNITY_WSA_10_0) || (ENABLE_IL2CPP && UNITY_WSA_10_0) EnableFlashlightAsync(colour); #endif }