ARKitSettings.cs
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using UnityEngine;
using UnityEngine.XR.Management;
using System.IO;
using System.Linq;
namespace UnityEditor.XR.ARKit
{
/// <summary>
/// Holds settings that are used to configure the ARKit XR Plugin.
/// </summary>
[System.Serializable]
[XRConfigurationData("ARKit", "UnityEditor.XR.ARKit.ARKitSettings")]
public class ARKitSettings : ScriptableObject
{
/// <summary>
/// Enum which defines whether ARKit is optional or required.
/// </summary>
public enum Requirement
{
/// <summary>
/// ARKit is required, which means the app cannot be installed on devices that do not support ARKit.
/// </summary>
Required,
/// <summary>
/// ARKit is optional, which means the the app can be installed on devices that do not support ARKit.
/// </summary>
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;
/// <summary>
/// Determines whether ARKit is required for this app: will make app only downloadable by devices with ARKit support if set to <see cref="Requirement.Required"/>.
/// </summary>
public Requirement requirement
{
get { return m_Requirement; }
set { m_Requirement = value; }
}
/// <summary>
/// Gets the currently selected settings, or create a default one if no <see cref="ARKitSettings"/> has been set in Player Settings.
/// </summary>
/// <returns>The ARKit settings to use for the current Player build.</returns>
public static ARKitSettings GetOrCreateSettings()
{
var settings = currentSettings;
if (settings != null)
return settings;
return CreateInstance<ARKitSettings>();
}
/// <summary>
/// Get or set the <see cref="ARKitSettings"/> that will be used for the player build.
/// </summary>
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()
{
return new SerializedObject(GetOrCreateSettings());
}
const string k_SettingsKey = "UnityEditor.XR.ARKit.ARKitSettings";
const string k_OldConfigObjectName = "com.unity.xr.arkit.PlayerSettings";
}
}