// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Microsoft.MixedReality.Toolkit.Editor; using System; using UnityEditor; using UnityEngine; namespace Microsoft.MixedReality.Toolkit.Utilities.Editor { /// /// Utility to check and configure UWP capability request from MRTK systems /// public class UWPCapabilityUtility { /// /// Given capability is required by the given component. Check if capability is enabled, if not auto-enable if possible and log to console /// /// Desired capability needed /// Component type that requires the associated capability to perform operations public static void RequireCapability(PlayerSettings.WSACapability capability, Type dependentComponent) { // Any changes made in editor while playing will not save if (!EditorApplication.isPlaying && !PlayerSettings.WSA.GetCapability(capability)) { if (MixedRealityProjectPreferences.AutoEnableUWPCapabilities) { Debug.Log($"{dependentComponent.Name} requires the UWP {capability} capability. Auto-enabling this capability in Player Settings.\nDisable this automation tool via MRTK Preferences under Project Settings."); PlayerSettings.WSA.SetCapability(capability, true); } else { Debug.LogWarning($"{dependentComponent.Name} requires the UWP {capability} capability which is currently not enabled. To utilize this component on device, enable the capability in Player Settings > Publishing Settings."); } } } } }