1 using System.Collections.Generic;
17 SerializedProperty p_EarthRadiusInKM;
18 SerializedProperty p_EarthEquatorialRadius;
19 SerializedProperty p_EarthFirstEccentricitySquared;
20 SerializedProperty p_UseVuforia;
21 SerializedProperty p_UseCustomGeoCalculator;
22 SerializedProperty p_InitialGroundHeightGuess;
23 SerializedProperty p_VuforiaGroundHitTestDistance;
24 private SerializedProperty p_MinGroundHeight;
25 private SerializedProperty p_MaxGroundHeight;
26 private SerializedProperty p_GroundHeightSmoothingFactor;
30 const string ARGPS_USE_VUFORIA =
"ARGPS_USE_VUFORIA";
31 const string ARGPS_USE_NATIVE_LOCATION =
"ARGPS_USE_NATIVE_LOCATION";
32 const string ARGPS_USE_CUSTOM_GEO_CALC =
"ARGPS_USE_CUSTOM_GEO_CALC";
34 Dictionary<string, string> defineSymbolProps =
new Dictionary<string, string> {
35 {ARGPS_USE_VUFORIA,
"UseVuforia"},
36 {ARGPS_USE_NATIVE_LOCATION,
"UseNativeLocationModule"}
39 private void OnEnable()
41 p_EarthRadiusInKM = serializedObject.FindProperty(
"EarthMeanRadiusInKM");
42 p_EarthEquatorialRadius = serializedObject.FindProperty(
"EarthEquatorialRadiusInKM");
43 p_EarthFirstEccentricitySquared = serializedObject.FindProperty(
"EarthFirstEccentricitySquared");
44 p_UseVuforia = serializedObject.FindProperty(
"UseVuforia");
45 p_UseCustomGeoCalculator = serializedObject.FindProperty(
"UseCustomGeoCalculator");
46 p_InitialGroundHeightGuess = serializedObject.FindProperty(
"InitialGroundHeightGuess");
47 p_VuforiaGroundHitTestDistance = serializedObject.FindProperty(
"VuforiaGroundHitTestDistance");
48 p_MinGroundHeight = serializedObject.FindProperty(
"MinGroundHeight");
49 p_MaxGroundHeight = serializedObject.FindProperty(
"MaxGroundHeight");
50 p_GroundHeightSmoothingFactor = serializedObject.FindProperty(
"GroundHeightSmoothingFactor");
55 BuildTargetGroup.Android
59 private void UpdateDefineSymbolsFromPlayerSettings()
61 defineSymbolsManager.UpdateFromBuildSettings();
63 foreach (var item
in defineSymbolProps)
65 if (item.Value ==
"UseVuforia")
67 #if !UNITY_2019_3_OR_NEWER
69 var value = defineSymbolsManager.Has(item.Key) && PlayerSettings.vuforiaEnabled;
71 var value = defineSymbolsManager.Has(item.Key) && PlayerSettings.GetPlatformVuforiaEnabled(BuildTargetGroup.Android) && PlayerSettings.GetPlatformVuforiaEnabled(BuildTargetGroup.iOS);
73 UpdateDefineSymbolProp(item.Value, value);
78 UpdateDefineSymbolProp(item.Value, defineSymbolsManager.Has(item.Key));
82 serializedObject.ApplyModifiedProperties();
85 private void UpdateDefineSymbolProp(
string propName,
bool value)
87 var prop = serializedObject.FindProperty(propName);
94 prop.boolValue = value;
98 public override void OnInspectorGUI()
100 serializedObject.Update();
102 UpdateDefineSymbolsFromPlayerSettings();
104 defineSymbolsManager.UpdateFromBuildSettings();
107 EditorGUILayout.HelpBox(
"AR+GPS Location " +
ARLocationConfig.Version, MessageType.None,
true);
108 EditorGUILayout.PropertyField(p_EarthRadiusInKM);
109 EditorGUILayout.PropertyField(p_EarthEquatorialRadius);
110 EditorGUILayout.PropertyField(p_EarthFirstEccentricitySquared);
111 EditorGUILayout.PropertyField(p_InitialGroundHeightGuess);
112 EditorGUILayout.PropertyField(p_MinGroundHeight);
113 EditorGUILayout.PropertyField(p_MaxGroundHeight);
114 EditorGUILayout.PropertyField(p_GroundHeightSmoothingFactor);
115 EditorGUILayout.PropertyField(p_VuforiaGroundHitTestDistance);
116 EditorGUILayout.PropertyField(p_UseVuforia);
117 EditorGUILayout.PropertyField(p_UseCustomGeoCalculator);
120 if (p_UseVuforia.boolValue)
122 #if UNITY_2019_3_OR_NEWER
123 EditorGUILayout.HelpBox(
"Make sure that Vuforia is instaled in the Package Manager Window. On Android, also make sure that the 'ARCore XR Plugin' is not installed.", MessageType.Info);
127 EditorGUILayout.HelpBox(
128 "Note that the regular sample scenes do not work with Vuforia. You can download a project with Vuforia samples at https://github.com/dmbfm/unity-ar-gps-location-issues/releases/tag/v3.1.1", MessageType.Warning);
132 if (GUILayout.Button(
"Open Documentation"))
134 Application.OpenURL(
"https://docs.unity-ar-gps-location.com");
139 UpdateDefineSymbolPropConfig(config.UseVuforia, p_UseVuforia.boolValue, ARGPS_USE_VUFORIA);
141 UpdateVuforiaPlayerSettings(config.UseVuforia, p_UseVuforia.boolValue);
143 UpdateDefineSymbolPropConfig(config.UseCustomGeoCalculator, p_UseCustomGeoCalculator.boolValue, ARGPS_USE_CUSTOM_GEO_CALC);
145 serializedObject.ApplyModifiedProperties();
148 private void UpdateVuforiaPlayerSettings(
bool oldValue,
bool newValue)
150 if (newValue == oldValue)
155 #if !UNITY_2019_3_OR_NEWER
159 PlayerSettings.vuforiaEnabled =
true;
163 PlayerSettings.vuforiaEnabled =
false;
168 PlayerSettings.SetPlatformVuforiaEnabled(BuildTargetGroup.Android,
true);
169 PlayerSettings.SetPlatformVuforiaEnabled(BuildTargetGroup.iOS,
true);
173 PlayerSettings.SetPlatformVuforiaEnabled(BuildTargetGroup.Android,
false);
174 PlayerSettings.SetPlatformVuforiaEnabled(BuildTargetGroup.iOS,
false);
181 private void UpdateDefineSymbolPropConfig(
bool oldValue,
bool newValue,
string symbol)
183 if (newValue == oldValue)
return;
187 defineSymbolsManager.Add(symbol);
191 defineSymbolsManager.Remove(symbol);
194 defineSymbolsManager.ApplyToBuildSettings();