using System; using UnityEngine; using UnityEngine.XR.Management; namespace UnityEditor.XR.ARKit { /// /// Holds settings that are used to configure the Apple ARKit XR Plug-in. /// [Serializable] [XRConfigurationData("Apple ARKit", "UnityEditor.XR.ARKit.ARKitSettings")] public class ARKitSettings : ScriptableObject { const string k_SettingsKey = "UnityEditor.XR.ARKit.ARKitSettings"; const string k_OldConfigObjectName = "com.unity.xr.arkit.PlayerSettings"; /// /// Enum which defines whether ARKit is optional or required. /// public enum Requirement { /// /// ARKit is required, which means the app cannot be installed on devices that do not support ARKit. /// Required, /// /// ARKit is optional, which means the the app can be installed on devices that do not support ARKit. /// Optional } [SerializeField, Tooltip("Toggles whether ARKit is required for this app. Will make app only downloadable by devices with ARKit support if set to 'Required'.")] Requirement m_Requirement; /// /// Determines whether ARKit is required for this app. If set to , the app can only be downloaded on devices with ARKit support. /// public Requirement requirement { get => m_Requirement; set => m_Requirement = value; } /// /// If true, includes ARKit Face Tracking functionality. If false, doesn't include ARKit Face Tracking functionality. /// public bool faceTracking { get => m_FaceTracking; set => m_FaceTracking = value; } [SerializeField, Tooltip("Includes ARKit Face Tracking functionality when toggled on.")] bool m_FaceTracking; /// /// Gets the currently selected settings, or creates default settings if no have been set in Player Settings. /// /// The ARKit settings to use for the current Player build. public static ARKitSettings GetOrCreateSettings() { var settings = currentSettings; if (settings != null) return settings; return CreateInstance(); } /// /// Get or set the to use for the Player build. /// public static ARKitSettings currentSettings { get => EditorBuildSettings.TryGetConfigObject(k_SettingsKey, out ARKitSettings settings) ? settings : null; set { if (value == null) { EditorBuildSettings.RemoveConfigObject(k_SettingsKey); } else { EditorBuildSettings.AddConfigObject(k_SettingsKey, value, true); } } } internal static bool TrySelect() { var settings = currentSettings; if (settings == null) return false; Selection.activeObject = settings; return true; } internal static SerializedObject GetSerializedSettings() => new(GetOrCreateSettings()); void Awake() { if (EditorBuildSettings.TryGetConfigObject(k_OldConfigObjectName, out ARKitSettings result)) { EditorBuildSettings.RemoveConfigObject(k_OldConfigObjectName); } } } }