Skip to content

Commit

Permalink
ARCore Extensions for AR Foundation v1.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tedruxpin committed Nov 9, 2020
1 parent 739ebd0 commit 13a10c4
Show file tree
Hide file tree
Showing 40 changed files with 850 additions and 314 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.20.0" minTargetSdk="11.0">
<iosPod name="ARCore/CloudAnchors" version="~> 1.21.0" minTargetSdk="11.0">
</iosPod>
</iosPods>
</dependencies>
4 changes: 4 additions & 0 deletions Editor/Scripts/Internal/ARCoreAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ private void OnAnalyticsUpdate()
{
if (_verbose == true)
{
#if UNITY_2020_2_OR_NEWER
if (_webRequest.result == UnityWebRequest.Result.ConnectionError)
#else
if (_webRequest.isNetworkError == true)
#endif
{
Debug.Log("Error sending Google ARCore SDK for Unity analytics: " +
_webRequest.error);
Expand Down
88 changes: 3 additions & 85 deletions Editor/Scripts/Internal/ARCoreExtensionsProjectSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Google.XR.ARCoreExtensions.Editor.Internal
using System.IO;
using System.Reflection;
using Google.XR.ARCoreExtensions;
using Google.XR.ARCoreExtensions.Internal;
using UnityEngine;

/// <summary>
Expand Down Expand Up @@ -157,15 +158,15 @@ public void Load()
if (AndroidAuthenticationStrategySetting == AndroidAuthenticationStrategy.None)
{
AndroidAuthenticationStrategySetting =
string.IsNullOrEmpty(Instance.AndroidCloudServicesApiKey) ?
string.IsNullOrEmpty(AndroidCloudServicesApiKey) ?
AndroidAuthenticationStrategy.Keyless :
AndroidAuthenticationStrategy.ApiKey;
}

if (IOSAuthenticationStrategySetting == IOSAuthenticationStrategy.None)
{
IOSAuthenticationStrategySetting =
string.IsNullOrEmpty(Instance.IOSCloudServicesApiKey) ?
string.IsNullOrEmpty(IOSCloudServicesApiKey) ?
IOSAuthenticationStrategy.AuthenticationToken :
IOSAuthenticationStrategy.ApiKey;
}
Expand Down Expand Up @@ -306,66 +307,6 @@ public HelpAttribute GetIosStrategyHelpInfo()
}
}

/// <summary>
/// Help attribute that displays the help message as a HelpBox below the property.
/// When uses HelpAttribute and other inspector attributes, make sure that the HelpAttribute
/// has the lowest order, otherwise it may not be drawn in the inspector.
/// NOTE:
/// When using HelpAttribute and TextAreaAttribute together, the text area will not have
/// a scrollbar.
/// HelpAttribute is incompatible with a custom type.
/// </summary>
public class HelpAttribute : PropertyAttribute
{
/// <summary>
/// The help message to display in the help box.
/// </summary>
public readonly string HelpMessage = null;

/// <summary>
/// The type of the help message which controls the icon in help box.
/// </summary>
public readonly HelpMessageType MessageType = HelpMessageType.None;

/// <summary>
/// Constructor for a HelpAttribute.
/// </summary>
/// <param name="helpMessage">Message to display.</param>
/// <param name="messageType"><see cref="HelpMessageType"/> for the help box.</param>
public HelpAttribute(string helpMessage,
HelpMessageType messageType = HelpMessageType.None)
{
HelpMessage = helpMessage;
MessageType = messageType;
}

/// <summary>
/// Help message types.
/// </summary>
public enum HelpMessageType
{
/// <summary>
/// Neutral message. MessageType: None.
/// </summary>
None,

/// <summary>
/// Info message. MessageType: Info.
/// </summary>
Info,

/// <summary>
/// Warning message. MessageType: Waring.
/// </summary>
Warning,

/// <summary>
/// Error message. MessageType: Error.
/// </summary>
Error,
}
}

/// <summary>
/// This attribute controls whether to display the field or not. The function name
/// would be input as the parameter to this attribute. Note, the function must return
Expand Down Expand Up @@ -411,29 +352,6 @@ public DisplayNameAttribute(string displayString)
}
}

/// <summary>
/// This attribute is used to generate a HelpBox based on the HelpAttribute
/// return by the given reflection function. Note, the function must return
/// the type HelpAttribute, take no parameters, and be a member of ARCoreProjectSettings.
/// </summary>
internal class DynamicHelpAttribute : Attribute
{
/// <summary>
/// Reflection function that return the type HelpAttribute, take no parameters,
/// and be a member of ARCoreProjectSettings.
/// </summary>
public readonly string CheckingFunction;

/// <summary>
/// Initializes a new instance of the `DynamicHelp` class.
/// </summary>
/// <param name="checkingFunction">Reflection function.</param>
public DynamicHelpAttribute(string checkingFunction)
{
CheckingFunction = checkingFunction;
}
}

/// <summary>
/// This attribute is used to control the enum ranges provided for popup.
/// The function must be a member of ARCoreProjectSettings, return the type
Expand Down
26 changes: 20 additions & 6 deletions Editor/Scripts/Internal/ARCoreExtensionsProjectSettingsGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ namespace Google.XR.ARCoreExtensions.Editor.Internal
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Google.XR.ARCoreExtensions.Internal;
using UnityEditor;
using UnityEngine;

internal class ARCoreExtensionsProjectSettingsGUI

/// <summary>
/// The GUI of ARCoreExtensionsProjectSettings.
/// </summary>
public class ARCoreExtensionsProjectSettingsGUI
{
private static readonly float _toggleLabelWidth = 180;
private static readonly float _groupLabelIndent = 15;
Expand Down Expand Up @@ -61,14 +66,23 @@ public static string[] GetEnumNames<T>(Array availbleEnums)
.ToArray();
}

// Render ARCore Project Settings for ARCoreProjectSettingsWindow and
// ARCoreProjectSettingsProvider.
internal static void OnGUI(bool renderForStandaloneWindow)
/// <summary>
/// Render ARCore Project Settings for ARCoreProjectSettingsWindow and
/// ARCoreProjectSettingsProvider.
/// </summary>
/// <param name="renderForStandaloneWindow">
/// Is the GUI rendered for standalone window.
/// </param>
public static void OnGUI(bool renderForStandaloneWindow)
{
DrawGUI(ARCoreExtensionsProjectSettings.Instance);
}

private static void DrawGUI(object targetObject)
/// <summary>
/// Auto GUI generating function.
/// </summary>
/// <param name="targetObject">The object instance to draw.</param>
public static void DrawGUI(object targetObject)
{
Type targetType = targetObject.GetType();
foreach (FieldInfo fieldInfo in targetType.GetFields())
Expand Down Expand Up @@ -183,7 +197,7 @@ private static void DrawGUI(object targetObject)
EditorGUILayout.EndHorizontal();
}

GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
DisplayHelpInfo(fieldInfo, targetObject);
}
}
Expand Down
6 changes: 4 additions & 2 deletions Editor/Scripts/Internal/AssetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

namespace Google.XR.ARCoreExtensions.Editor.Internal
{
using System.Diagnostics.CodeAnalysis;
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEngine;

internal class AssetHelper
/// <summary>
/// Helper methods to handle Unity assets.
/// </summary>
public class AssetHelper
{
/// <summary>
/// Get a PluginImporter object for a specific plugin file, anywhere in the project.
Expand Down
2 changes: 1 addition & 1 deletion Editor/Scripts/Internal/IOSSupportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static void UpdateIOSScriptingDefineSymbols(bool arcoreIOSEnabled)
{
Debug.LogFormat("Removing {0} define symbol.", _arCoreExtensionIOSSupportSymbol);
iOSScriptingDefineSymbols = iOSScriptingDefineSymbols.Replace(
_arCoreExtensionIOSSupportSymbol, string.Empty);
_arCoreExtensionIOSSupportSymbol, string.Empty);
PlayerSettings.SetScriptingDefineSymbolsForGroup(
BuildTargetGroup.iOS, iOSScriptingDefineSymbols);
}
Expand Down
8 changes: 8 additions & 0 deletions Editor/Scripts/Internal/PropertyDrawers.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//-----------------------------------------------------------------------
// <copyright file="DynamicHelpAttributeDrawer.cs" company="Google LLC">
//
// Copyright 2020 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>
//-----------------------------------------------------------------------

namespace Google.XR.ARCoreExtensions.Editor.Internal
{
using System;
using System.Reflection;
using Google.XR.ARCoreExtensions.Internal;
using UnityEditor;

/// <summary>
/// DynamicHelpAttributeHelpAttribute drawer that draws a HelpBox below the property to
/// display the help content based on the given condition.
/// </summary>
[CustomPropertyDrawer(typeof(DynamicHelpAttribute))]
public class DynamicHelpAttributeDrawer : HelpAttributeDrawer
{
/// <summary>
/// Get the underlying <see cref="HelpAttribute"/> of this drawer.
/// </summary>
/// <param name="property">The target SerializedProperty.</param>
/// <returns>The HelpAttribute of the given property. It could be null based on
/// the condition function.</returns>
protected override HelpAttribute GetHelpAttribute(SerializedProperty property)
{
DynamicHelpAttribute dynamicHelpAttribute = attribute as DynamicHelpAttribute;
Type targetType = property.serializedObject.targetObject.GetType();
MethodInfo checkingFunction =
targetType.GetMethod(dynamicHelpAttribute.CheckingFunction);
HelpAttribute helpAttribute = (HelpAttribute)checkingFunction.Invoke(
property.serializedObject.targetObject,
new object[] { });

return helpAttribute;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 13a10c4

Please sign in to comment.