Skip to content

Commit

Permalink
ARCore Extensions for AR Foundation v1.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tedruxpin committed Dec 11, 2020
1 parent 13a10c4 commit bab65af
Show file tree
Hide file tree
Showing 53 changed files with 1,547 additions and 72 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.21.0" minTargetSdk="11.0">
<iosPod name="ARCore/CloudAnchors" version="~> 1.22.0" minTargetSdk="11.0">
</iosPod>
</iosPods>
</dependencies>
14 changes: 7 additions & 7 deletions Editor/Scripts/Internal/ARCoreExtensionsProjectSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void Save()
}

/// <summary>
/// Refelection function used by 'DisplayCondition' for property
/// Reflection function used by 'DisplayCondition' for property
/// 'AndroidCloudServicesApiKey'.
/// </summary>
/// <returns>Display condition for 'AndroidCloudServicesApiKey'.</returns>
Expand All @@ -209,7 +209,7 @@ public bool IsAndroidApiKeyFieldDisplayed()
}

/// <summary>
/// Refelection function used by 'DynamicHelp' for property
/// Reflection function used by 'DynamicHelp' for property
/// 'AndroidAuthenticationStrategySetting'.
/// </summary>
/// <returns>Help info for 'AndroidAuthenticationStrategySetting'.</returns>
Expand All @@ -229,7 +229,7 @@ public HelpAttribute GetAndroidStrategyHelpInfo()
}

/// <summary>
/// Refelection function used by 'EnumRange' for property
/// Reflection function used by 'EnumRange' for property
/// 'AndroidAuthenticationStrategySetting'.
/// </summary>
/// <returns>Enum range for 'AndroidAuthenticationStrategySetting'.</returns>
Expand All @@ -243,7 +243,7 @@ public Array GetAndroidStrategyRange()
}

/// <summary>
/// Refelection function used by 'DisplayCondition' for property
/// Reflection function used by 'DisplayCondition' for property
/// 'IOSAuthenticationStrategySetting'.
/// </summary>
/// <returns>Display condition for 'IOSAuthenticationStrategySetting'.</returns>
Expand All @@ -253,7 +253,7 @@ public bool IsIosStrategyDisplayed()
}

/// <summary>
/// Refelection function used by 'DisplayCondition' for property 'IOSCloudServicesApiKey'.
/// Reflection function used by 'DisplayCondition' for property 'IOSCloudServicesApiKey'.
/// </summary>
/// <returns>Display condition for 'IOSCloudServicesApiKey'.</returns>
public bool IsIosApiKeyFieldDisplayed()
Expand All @@ -275,7 +275,7 @@ public bool IsIosApiKeyFieldDisplayed()
}

/// <summary>
/// Refelection function used by 'EnumRange' for property 'IOSAuthenticationStrategy'.
/// Reflection function used by 'EnumRange' for property 'IOSAuthenticationStrategy'.
/// </summary>
/// <returns>Enum range for 'IOSAuthenticationStrategy'.</returns>
public Array GetIosStrategyRange()
Expand All @@ -288,7 +288,7 @@ public Array GetIosStrategyRange()
}

/// <summary>
/// Refelection function used by 'DynamicHelp' for property 'IOSAuthenticationStrategy'.
/// Reflection function used by 'DynamicHelp' for property 'IOSAuthenticationStrategy'.
/// </summary>
/// <returns>Help info for 'IOSAuthenticationStrategy'.</returns>
public HelpAttribute GetIosStrategyHelpInfo()
Expand Down
12 changes: 7 additions & 5 deletions Editor/Scripts/Internal/AndroidDependenciesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Google.XR.ARCoreExtensions.Editor.Internal
/// This handles the addition and removal android dependencies, and run PlayServicesResolver
/// plugin.
/// </summary>
internal static class AndroidDependenciesHelper
public static class AndroidDependenciesHelper
{
private static readonly string _templateFileExtension = ".template";
private static readonly string _playServiceDependencyFileExtension = ".xml";
Expand Down Expand Up @@ -90,15 +90,17 @@ public static void UpdateAndroidDependencies(bool enabledDependencies,
if (enabledDependencies && !File.Exists(dependenciesXMLPath))
{
Debug.LogFormat(
"Adding {0}.", Path.GetFileNameWithoutExtension(dependenciesTemplatePath));
"Adding {0}.",
System.IO.Path.GetFileNameWithoutExtension(dependenciesTemplatePath));

File.Copy(dependenciesTemplatePath, dependenciesXMLPath);
AssetDatabase.Refresh();
}
else if (!enabledDependencies && File.Exists(dependenciesXMLPath))
{
Debug.LogFormat(
"Removing {0}.", Path.GetFileNameWithoutExtension(dependenciesTemplatePath));
"Removing {0}.",
System.IO.Path.GetFileNameWithoutExtension(dependenciesTemplatePath));

File.Delete(dependenciesXMLPath);
File.Delete(dependenciesXMLPath + ".meta");
Expand Down Expand Up @@ -208,9 +210,9 @@ public static string GetJdkPath()
}

if (!string.IsNullOrEmpty(jdkPath) &&
(File.GetAttributes(jdkPath) & FileAttributes.Directory) == 0)
(File.GetAttributes(jdkPath) & System.IO.FileAttributes.Directory) == 0)
{
Debug.LogError(string.Format("Invalid JDK path '{0}'", jdkPath));
Debug.LogErrorFormat("Invalid JDK path '{0}'", jdkPath);
jdkPath = null;
}

Expand Down
47 changes: 32 additions & 15 deletions Editor/Scripts/Internal/AndroidKeylessPreprocessBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ namespace Google.XR.ARCoreExtensions.Editor.Internal
/// This handles the addition and removal of dependencies into the App's build.
/// For BatchMode builds, perform clean after a build is complete.
/// </summary>
internal class AndroidKeylessPreprocessBuild : IPreprocessBuildWithReport
public class AndroidKeylessPreprocessBuild : IPreprocessBuildWithReport
{
private const string _androidKeylessPluginGuid = "aafa8cb6617464d6290c8fdfb9607794";
private const string _androidKeylessDependenciesGuid = "1fc346056f53a42949a3dcadaae39d67";

/// <summary>
/// Gets Callback order.
/// </summary>
[SuppressMessage("UnityRules.UnityStyleRules",
"US1109:PublicPropertiesMustBeUpperCamelCase", Justification = "Overriden property.")]
public int callbackOrder
Expand All @@ -46,6 +49,11 @@ public int callbackOrder
}
}

/// <summary>
/// Callback after the build is done.
/// </summary>
/// <param name="target">Build target platform.</param>
/// <param name="pathToBuiltProject">Path to build project.</param>
[PostProcessBuild(1)]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
{
Expand All @@ -55,6 +63,29 @@ public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProj
}
}

/// <summary>
/// Preprocess step for Android Build.
/// </summary>
/// <param name="enabledKeyless">Whether to enable or disable keyless.</param>
public static void PreprocessAndroidBuild(bool enabledKeyless)
{
AndroidDependenciesHelper.SetAndroidPluginEnabled(
enabledKeyless, _androidKeylessPluginGuid);
AndroidDependenciesHelper.UpdateAndroidDependencies(
enabledKeyless, _androidKeylessDependenciesGuid);

if (enabledKeyless)
{
Debug.Log("ARCoreExtensions: Including Keyless dependencies in this build.");
AndroidDependenciesHelper.DoPlayServicesResolve();
}
}

/// <summary>
/// Callback before the build is started.
/// </summary>
/// <param name="report">A report containing information about the build,
/// such as its target platform and output path.</param>
public void OnPreprocessBuild(BuildReport report)
{
if (report.summary.platform == BuildTarget.Android)
Expand All @@ -69,20 +100,6 @@ public void OnPreprocessBuild(BuildReport report)
}
}

private static void PreprocessAndroidBuild(bool enabledKeyless)
{
AndroidDependenciesHelper.SetAndroidPluginEnabled(
enabledKeyless, _androidKeylessPluginGuid);
AndroidDependenciesHelper.UpdateAndroidDependencies(
enabledKeyless, _androidKeylessDependenciesGuid);

if (enabledKeyless)
{
Debug.Log("ARCoreExtensions: Including Keyless dependencies in this build.");
AndroidDependenciesHelper.DoPlayServicesResolve();
}
}

private static void PostprocessAndroidBuild()
{
Debug.Log("ARCoreExtensions: Cleaning up Keyless dependencies.");
Expand Down
24 changes: 18 additions & 6 deletions Editor/Scripts/Internal/AndroidSupportPreprocessBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace Google.XR.ARCoreExtensions.Editor.Internal
{
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
Expand All @@ -31,13 +30,19 @@ namespace Google.XR.ARCoreExtensions.Editor.Internal
using UnityEngine.XR.ARCore;
using UnityEngine.XR.Management;

internal class AndroidSupportPreprocessBuild : IPreprocessBuildWithReport
/// <summary>
/// Preprocess build to check android support.
/// </summary>
public class AndroidSupportPreprocessBuild : IPreprocessBuildWithReport
{
private const string _mainTempatePath = "Plugins/Android/mainTemplate.gradle";
private const string _mainTemplatePath = "Plugins/Android/mainTemplate.gradle";
private const string _launcherTemplatePath = "Plugins/Android/launcherTemplate.gradle";

[SuppressMessage("UnityRules.UnityStyleRules",
"US1109:PublicPropertiesMustBeUpperCamelCase",
/// <summary>
/// Gets the relative callback order for callbacks. Callbacks with lower values are called
/// before ones with higher values.
/// </summary>
[SuppressMessage("UnityRules.UnityStyleRules", "US1109:PublicPropertiesMustBeUpperCamelCase",
Justification = "Overriden property.")]
public int callbackOrder
{
Expand All @@ -47,9 +52,16 @@ public int callbackOrder
}
}

/// <summary>
/// A callback received before the build is started.
/// </summary>
/// <param name="report">A report containing information about the build,
/// such as its target platform and output path.</param>
public void OnPreprocessBuild(BuildReport report)
{
#if !ARCORE_FEATURE_UNIT_TEST // BuildReport is unavailable on Test Welder.
if (report.summary.platform == BuildTarget.Android)
#endif
{
if (!CheckARCoreLoader())
{
Expand Down Expand Up @@ -117,7 +129,7 @@ private void CheckGradleTemplate()

// Need to use gradle plugin version >= 3.6.0 in main gradle by editing
// 'Assets/Plugins/Android/mainTemplate.gradle'.
if (!File.Exists(Path.Combine(Application.dataPath, _mainTempatePath)))
if (!File.Exists(Path.Combine(Application.dataPath, _mainTemplatePath)))
{
throw new BuildFailedException(
"Main Gradle template is not used in this build. " +
Expand Down
16 changes: 15 additions & 1 deletion Editor/Scripts/Internal/IOSSupportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ namespace Google.XR.ARCoreExtensions.Editor.Internal
using UnityEditor;
using UnityEngine;

internal static class IOSSupportHelper
/// <summary>
/// IOS support helper class.
/// </summary>
public static class IOSSupportHelper
{
// GUID of folder [ARCore Extensions Package]/Editor/BuildResources/
private const string _arCoreIOSDependencyFolderGUID = "117437286c43f4eeb845c3257f2a8546";

private const string _arCoreIOSDependencyFileName = "ARCoreiOSDependencies";
private const string _arCoreExtensionIOSSupportSymbol = "ARCORE_EXTENSIONS_IOS_SUPPORT";

/// <summary>
/// Enables ARCore iOS Support in Extensions.
/// </summary>
/// <param name="arcoreIOSEnabled">Indicates whether to enable or disable iOS support.
/// </param>
public static void SetARCoreIOSSupportEnabled(bool arcoreIOSEnabled)
{
if (arcoreIOSEnabled)
Expand All @@ -50,6 +58,12 @@ public static void SetARCoreIOSSupportEnabled(bool arcoreIOSEnabled)
UpdateIOSPodDependencies(arcoreIOSEnabled, _arCoreIOSDependencyFileName);
}

/// <summary>
/// Updates the iOS pod dependency based on iOS support state.
/// </summary>
/// <param name="arcoreIOSEnabled">Enable or disable the dependency.
/// </param>
/// <param name="dependencyFileName">The file name of the dependency template.</param>
public static void UpdateIOSPodDependencies(bool arcoreIOSEnabled,
string dependencyFileName)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//-----------------------------------------------------------------------
// <copyright file="EnumFlagsAttributeDrawer.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 Google.XR.ARCoreExtensions.Internal;
using UnityEditor;
using UnityEngine;

/// <summary>
/// EnumFlagsAttribute drawer that draws a mask field and calculate the int value based on
/// current enum values.
/// </summary>
[CustomPropertyDrawer(typeof(EnumFlagsAttribute))]
public class EnumFlagsAttributeDrawer : PropertyDrawer
{
/// <summary>
/// Override Unity OnGUI to make a custom GUI for the property with EnumFlagsAttribute.
/// </summary>
/// <param name="position">Rectangle on the screen to use for the property GUI.</param>
/// <param name="property">The SerializedProperty to make the custom GUI for.</param>
/// <param name="label">The label of this property.</param>
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EnumFlagsAttribute flagsAttribute = attribute as EnumFlagsAttribute;

string[] itemNames = Enum.GetNames(flagsAttribute.EnumType);
int[] itemValues = Enum.GetValues(flagsAttribute.EnumType) as int[];

property.intValue =
EditorGUI.MaskField(position, label, property.intValue, itemNames);

if (property.intValue == -1)
{
int maskValue = 0;
foreach (int itemValue in itemValues)
{
maskValue |= itemValue;
}

property.intValue = maskValue;
}
}
}
}

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

Binary file modified Runtime/Plugins/ARPresto.aar
Binary file not shown.
Binary file modified Runtime/Plugins/arcore_client.aar
Binary file not shown.
Binary file modified Runtime/Plugins/cloud_anchor_manifest.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion Runtime/Plugins/cloud_anchor_manifest.aar.meta

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

Binary file modified Runtime/Plugins/keyless_authentication.aar
Binary file not shown.
Loading

0 comments on commit bab65af

Please sign in to comment.