// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Microsoft.MixedReality.Toolkit.Utilities.Editor; using System.IO; using UnityEditor; namespace Microsoft.MixedReality.Toolkit.Experimental.UnityAR { /// /// Class to perform checks for configuration checks for the UnityAR provider. /// /// /// Note that the checks that this class runs are fairly expensive and are only done manually by the user /// as part of their setup steps described here: /// https://docs.microsoft.com/windows/mixed-reality/mrtk-unity/supported-devices/using-ar-foundation /// static class UnityARConfigurationChecker { private const string FileName = "Unity.XR.ARFoundation.asmdef"; private static readonly string[] definitions = { "ARFOUNDATION_PRESENT" }; /// /// Ensures that the appropriate symbolic constant is defined based on the presence of the AR Foundation package. /// /// True if the define was added, false otherwise. [MenuItem("Mixed Reality/Toolkit/Utilities/UnityAR/Update Scripting Defines")] private static bool ReconcileArFoundationDefine() { FileInfo[] files = FileUtilities.FindFilesInPackageCache(FileName); if (files.Length > 0) { ScriptUtilities.AppendScriptingDefinitions(BuildTargetGroup.Android, definitions); ScriptUtilities.AppendScriptingDefinitions(BuildTargetGroup.iOS, definitions); return true; } else { ScriptUtilities.RemoveScriptingDefinitions(BuildTargetGroup.Android, definitions); ScriptUtilities.RemoveScriptingDefinitions(BuildTargetGroup.iOS, definitions); return false; } } } }