Skip to content

Commit

Permalink
ARCore Extensions for AR Foundation v1.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tedruxpin committed Aug 31, 2020
1 parent 35dbedc commit 74feedf
Show file tree
Hide file tree
Showing 43 changed files with 894 additions and 574 deletions.
2 changes: 1 addition & 1 deletion Editor/BuildResources/ARCoreiOSDependencies.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dependencies>
<iosPods>
<iosPod name="ARCore/CloudAnchors" version="~> 1.18.0" minTargetSdk="11.0">
<iosPod name="ARCore/CloudAnchors" version="~> 1.19.0" minTargetSdk="11.0">
</iosPod>
</iosPods>
</dependencies>
16 changes: 13 additions & 3 deletions Editor/Google.XR.ARCoreExtensions.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{
{
"name": "Google.XR.ARCoreExtensions.Editor",
"references": [
"Google.XR.ARCoreExtensions"
"Google.XR.ARCoreExtensions",
"Unity.XR.Management",
"Unity.XR.Management.Editor",
"Unity.XR.ARCore"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": []
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
48 changes: 24 additions & 24 deletions Editor/Scripts/Internal/ARCoreAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ namespace Google.XR.ARCoreExtensions.Editor.Internal
public class ARCoreAnalytics
{
public bool EnableAnalytics;
private const string k_EnableAnalyticsKey = "EnableGoogleARCoreExtensionsAnalytics";
private const string k_GoogleAnalyticsHost = "https://play.googleapis.com/log";
private const long k_AnalyticsResendDelayTicks = TimeSpan.TicksPerDay * 7;
private long m_LastUpdateTicks;
private bool m_Verbose;
private UnityWebRequest m_WebRequest;
private const string _enableAnalyticsKey = "EnableGoogleARCoreExtensionsAnalytics";
private const string _googleAnalyticsHost = "https://play.googleapis.com/log";
private const long _analyticsResendDelayTicks = TimeSpan.TicksPerDay * 7;
private long _lastUpdateTicks;
private bool _verbose;
private UnityWebRequest _webRequest;

/// <summary>
/// Static constructor permits a once-on-load analytics collection event.
Expand All @@ -53,11 +53,11 @@ static ARCoreAnalytics()
Instance.Load();

// Send analytics immediately.
Instance.SendAnalytics(k_GoogleAnalyticsHost, LogRequestUtils.BuildLogRequest(), false);
Instance.SendAnalytics(_googleAnalyticsHost, LogRequestUtils.BuildLogRequest(), false);

// Use the Editor Update callback to monitor the communication to the server.
EditorApplication.update +=
new EditorApplication.CallbackFunction(Instance._OnAnalyticsUpdate);
new EditorApplication.CallbackFunction(Instance.OnAnalyticsUpdate);
}

public static ARCoreAnalytics Instance { get; private set; }
Expand All @@ -67,15 +67,15 @@ static ARCoreAnalytics()
/// </summary>
public void Load()
{
EnableAnalytics = EditorPrefs.GetBool(k_EnableAnalyticsKey, true);
EnableAnalytics = EditorPrefs.GetBool(_enableAnalyticsKey, true);
}

/// <summary>
/// Saves current analytics preferences.
/// </summary>
public void Save()
{
EditorPrefs.SetBool(k_EnableAnalyticsKey, EnableAnalytics);
EditorPrefs.SetBool(_enableAnalyticsKey, EnableAnalytics);
}

/// <summary>
Expand All @@ -87,7 +87,7 @@ public void Save()
public void SendAnalytics(string analyticsHost, LogRequest logRequest, bool verbose)
{
// Save the time sending was last attempted.
m_LastUpdateTicks = DateTime.Now.Ticks;
_lastUpdateTicks = DateTime.Now.Ticks;

// Only send if analytics is enabled.
if (EnableAnalytics == false)
Expand All @@ -101,7 +101,7 @@ public void SendAnalytics(string analyticsHost, LogRequest logRequest, bool verb
}

// Only allow one instance of the request at a time.
if (m_WebRequest != null)
if (_webRequest != null)
{
if (verbose == true)
{
Expand All @@ -120,21 +120,21 @@ public void SendAnalytics(string analyticsHost, LogRequest logRequest, bool verb
webRequest.SendWebRequest();

// Set the verbosity preference for this request.
m_Verbose = verbose;
_verbose = verbose;
if (verbose == true)
{
Debug.Log("Sending Google ARCore SDK for Unity analytics.");
}

// The editor callback will follow through with this request.
m_WebRequest = webRequest;
_webRequest = webRequest;
}

/// <summary>
/// Periodically checks back to update the current logging request, or if
/// enough time has passed, initiate a new logging request.
/// </summary>
private void _OnAnalyticsUpdate()
private void OnAnalyticsUpdate()
{
// Nothing to do if Analytics isn't enabled.
if (EnableAnalytics == false)
Expand All @@ -143,33 +143,33 @@ private void _OnAnalyticsUpdate()
}

// Process the current web request.
if (m_WebRequest != null)
if (_webRequest != null)
{
if (m_WebRequest.isDone == true)
if (_webRequest.isDone == true)
{
if (m_Verbose == true)
if (_verbose == true)
{
if (m_WebRequest.isNetworkError == true)
if (_webRequest.isNetworkError == true)
{
Debug.Log("Error sending Google ARCore SDK for Unity analytics: " +
m_WebRequest.error);
_webRequest.error);
}
else
{
Debug.Log("Google ARCore SDK for Unity analytics sent: " +
m_WebRequest.downloadHandler.text);
_webRequest.downloadHandler.text);
}
}

m_WebRequest = null;
_webRequest = null;
}
}

// Resend analytics periodically (once per week if the editor remains open.)
if (DateTime.Now.Ticks - m_LastUpdateTicks >= k_AnalyticsResendDelayTicks)
if (DateTime.Now.Ticks - _lastUpdateTicks >= _analyticsResendDelayTicks)
{
Instance.SendAnalytics(
k_GoogleAnalyticsHost, LogRequestUtils.BuildLogRequest(), false);
_googleAnalyticsHost, LogRequestUtils.BuildLogRequest(), false);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Editor/Scripts/Internal/ARCoreAnalyticsGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ internal class ARCoreAnalyticsGUI
public static readonly string SDKHelpText =
"This setting is stored in Unity's Editor Preferences.";

private static float s_GroupLabelWidth = 280;
private static float _groupLabelWidth = 280;

// Render ARCore Analytics Settings for ARCoreAnalyticsProvider and
// ARCoreAnalyticsPreferences.
internal static void OnGUI()
{
EditorGUIUtility.labelWidth = s_GroupLabelWidth;
EditorGUIUtility.labelWidth = _groupLabelWidth;
ARCoreAnalytics.Instance.EnableAnalytics =
EditorGUILayout.Toggle(SDKAnalytics, ARCoreAnalytics.Instance.EnableAnalytics);
EditorGUILayout.HelpBox(SDKHelpText, MessageType.Info);
Expand Down
18 changes: 9 additions & 9 deletions Editor/Scripts/Internal/ARCoreExtensionsProjectSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,33 @@ internal class ARCoreExtensionsProjectSettings
public string AndroidCloudServicesApiKey;
public string IOSCloudServicesApiKey;

private const string k_ProjectSettingsPath =
private const string _projectSettingsPath =
"ProjectSettings/ARCoreExtensionsProjectSettings.json";

private static ARCoreExtensionsProjectSettings s_Instance = null;
private static ARCoreExtensionsProjectSettings _instance = null;

public static ARCoreExtensionsProjectSettings Instance
{
get
{
if (s_Instance == null)
if (_instance == null)
{
s_Instance = new ARCoreExtensionsProjectSettings();
s_Instance.Load();
_instance = new ARCoreExtensionsProjectSettings();
_instance.Load();
}

return s_Instance;
return _instance;
}
}

public void Load()
{
// If a settings file exists, load it now.
if (File.Exists(k_ProjectSettingsPath))
if (File.Exists(_projectSettingsPath))
{
ARCoreExtensionsProjectSettings settings =
JsonUtility.FromJson<ARCoreExtensionsProjectSettings>(
File.ReadAllText(k_ProjectSettingsPath));
File.ReadAllText(_projectSettingsPath));

IsIOSSupportEnabled = settings.IsIOSSupportEnabled;
AndroidCloudServicesApiKey = settings.AndroidCloudServicesApiKey;
Expand All @@ -81,7 +81,7 @@ public void Save()
{
try
{
File.WriteAllText(k_ProjectSettingsPath, JsonUtility.ToJson(this));
File.WriteAllText(_projectSettingsPath, JsonUtility.ToJson(this));
}
catch (Exception e)
{
Expand Down
22 changes: 11 additions & 11 deletions Editor/Scripts/Internal/ARCoreExtensionsProjectSettingsGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ internal class ARCoreExtensionsProjectSettingsGUI
public static readonly GUIContent Android = new GUIContent("Android");
public static readonly GUIContent IOS = new GUIContent("iOS");

private static float s_GroupLabelIndent = 15;
private static float s_GroupFieldIndent =
EditorGUIUtility.labelWidth - s_GroupLabelIndent;
private static bool s_FoldoutCloudAnchorAPIKeys = true;
private static float _groupLabelIndent = 15;
private static float _groupFieldIndent =
EditorGUIUtility.labelWidth - _groupLabelIndent;
private static bool _foldoutCloudAnchorAPIKeys = true;

internal static void OnGUI(bool renderForStandaloneWindow)
{
bool newIOSEnabled = EditorGUILayout.Toggle(IsIOSSupportEnabled,
ARCoreExtensionsProjectSettings.Instance.IsIOSSupportEnabled);
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);

s_FoldoutCloudAnchorAPIKeys =
EditorGUILayout.Foldout(s_FoldoutCloudAnchorAPIKeys, CloudAnchorAPIKeys);
if (s_FoldoutCloudAnchorAPIKeys)
_foldoutCloudAnchorAPIKeys =
EditorGUILayout.Foldout(_foldoutCloudAnchorAPIKeys, CloudAnchorAPIKeys);
if (_foldoutCloudAnchorAPIKeys)
{
// Draw text field for Android Cloud Anchor API Key.
EditorGUILayout.BeginHorizontal();
GUILayout.Space(s_GroupLabelIndent);
EditorGUILayout.LabelField(Android, GUILayout.Width(s_GroupFieldIndent));
GUILayout.Space(_groupLabelIndent);
EditorGUILayout.LabelField(Android, GUILayout.Width(_groupFieldIndent));
ARCoreExtensionsProjectSettings.Instance.AndroidCloudServicesApiKey =
EditorGUILayout.TextField(
ARCoreExtensionsProjectSettings.Instance.AndroidCloudServicesApiKey);
Expand All @@ -65,8 +65,8 @@ internal static void OnGUI(bool renderForStandaloneWindow)
if (newIOSEnabled)
{
EditorGUILayout.BeginHorizontal();
GUILayout.Space(s_GroupLabelIndent);
EditorGUILayout.LabelField(IOS, GUILayout.Width(s_GroupFieldIndent));
GUILayout.Space(_groupLabelIndent);
EditorGUILayout.LabelField(IOS, GUILayout.Width(_groupFieldIndent));
ARCoreExtensionsProjectSettings.Instance.IOSCloudServicesApiKey =
EditorGUILayout.TextField(
ARCoreExtensionsProjectSettings.Instance.IOSCloudServicesApiKey);
Expand Down
20 changes: 20 additions & 0 deletions Editor/Scripts/Internal/Analytics/ArcoreClearcut.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
//-----------------------------------------------------------------------
// <copyright file="ARCoreClearcut.cs" company="Google LLC">
//
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// </copyright>
//-----------------------------------------------------------------------

// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: arcore_clearcut.proto
Expand Down
20 changes: 20 additions & 0 deletions Editor/Scripts/Internal/Analytics/ArcoreSdkLog.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
//-----------------------------------------------------------------------
// <copyright file="ARCoreSdkLog.cs" company="Google LLC">
//
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// </copyright>
//-----------------------------------------------------------------------

// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: arcore_sdk_log.proto
Expand Down
Loading

0 comments on commit 74feedf

Please sign in to comment.