/// <summary>
        /// Manage the ios dependecies based on the project settings.
        /// </summary>
        /// <param name="settings">
        /// The <see cref="ARCoreExtensionsProjectSettings"/> used by current build.
        /// </param>
        public void ManageIOSDependencies(ARCoreExtensionsProjectSettings settings)
        {
            _enabledIOSTemplate.Clear();
            List <IDependentModule> featureModules = DependentModulesManager.GetModules();

            foreach (IDependentModule module in featureModules)
            {
                string iOSDependenciesTemplateFile = module.GetIOSDependenciesTemplateFileName();
                if (!string.IsNullOrEmpty(iOSDependenciesTemplateFile))
                {
                    bool isModuleEnabled = module.IsEnabled(
                        settings, UnityEditor.BuildTarget.iOS);
                    if (isModuleEnabled)
                    {
                        Debug.LogFormat("ARCoreExtensions: Include {0} for {1}.",
                                        iOSDependenciesTemplateFile, module.GetType().Name);
                        _enabledIOSTemplate.Add(iOSDependenciesTemplateFile);
                        IOSSupportHelper.UpdateIOSPodDependencies(
                            true, iOSDependenciesTemplateFile);
                    }
                    else
                    {
                        Debug.LogFormat("ARCoreExtensions: Exclude {0} for {1}.",
                                        iOSDependenciesTemplateFile, module.GetType().Name);
                        IOSSupportHelper.UpdateIOSPodDependencies(
                            false, iOSDependenciesTemplateFile);
                    }
                }
            }
        }
 public static void OnPostprocessBuild(
     UnityEditor.BuildTarget target, string pathToBuiltProject)
 {
     if (!UnityEditorInternal.InternalEditorUtility.inBatchMode)
     {
         // Only clean up resolver in Batch Mode.
         return;
     }
     if (target == UnityEditor.BuildTarget.Android)
     {
         Debug.Log("ARCoreExtensions: Cleaning up Android library dependencies.");
         string folderPath = Application.dataPath + _dependenciesDirectory;
         Directory.Delete(folderPath, true);
         AssetDatabase.Refresh();
         AndroidDependenciesHelper.DoPlayServicesResolve();
     }
     else if (target == UnityEditor.BuildTarget.iOS)
     {
         foreach (string enabledTemplateFile in _enabledIOSTemplate)
         {
             Debug.LogFormat("ARCoreExtensions: Cleaning up {0} in PostprocessBuild.",
                             enabledTemplateFile);
             IOSSupportHelper.UpdateIOSPodDependencies(false, enabledTemplateFile);
         }
     }
 }
        /// <summary>
        /// Manage the ios dependencies based on the project settings.
        /// </summary>
        /// <param name="settings">
        /// The <see cref="ARCoreExtensionsProjectSettings"/> used by current build.
        /// </param>
        public void ManageIOSDependencies(ARCoreExtensionsProjectSettings settings)
        {
            _enabledIOSTemplate.Clear();
            List <IDependentModule> featureModules = DependentModulesManager.GetModules();

            foreach (IDependentModule module in featureModules)
            {
                string[] iOSDependenciesTemplates = module.GetIOSDependenciesTemplateFileNames();
                if (iOSDependenciesTemplates != null && iOSDependenciesTemplates.Length > 0)
                {
                    bool isModuleEnabled = module.IsEnabled(
                        settings, UnityEditor.BuildTarget.iOS);
                    foreach (string iOSDependenciesTemplateFile in iOSDependenciesTemplates)
                    {
                        if (!string.IsNullOrEmpty(iOSDependenciesTemplateFile))
                        {
                            Debug.LogFormat("ARCoreExtensions: {0} {1} for {2}.",
                                            isModuleEnabled ? "Include" : "Exclude",
                                            iOSDependenciesTemplateFile,
                                            module.GetType().Name);
                            IOSSupportHelper.UpdateIOSPodDependencies(
                                isModuleEnabled, iOSDependenciesTemplateFile);
                            if (isModuleEnabled)
                            {
                                _enabledIOSTemplate.Add(iOSDependenciesTemplateFile);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// A callback before the build is started to enable IOS support.
        /// </summary>
        /// <param name="report">A report containing information about the build.</param>
        public void OnPreprocessBuild(BuildReport report)
        {
            if (report.summary.platform == BuildTarget.iOS)
            {
                bool arcoreiOSEnabled =
                    ARCoreExtensionsProjectSettings.Instance.IsIOSSupportEnabled;
                Debug.LogFormat("Building application with ARCore Extensions for AR Foundation " +
                                "iOS Support {0}", arcoreiOSEnabled ? "ENABLED" : "DISABLED");

                // Setup scripting define symbols:
                IOSSupportHelper.UpdateIOSScriptingDefineSymbols(
                    ARCoreExtensionsProjectSettings.Instance);

                // Setup CocoaPod templates:
                IOSSupportHelper.UpdateIOSPodDependencies(
                    arcoreiOSEnabled, IOSSupportHelper.ARCoreIOSDependencyFileName);
                Dictionary <string, bool> templates =
                    ARCoreExtensionsProjectSettings.Instance.GetIOSDependenciesStatus();
                foreach (var keyvalue in templates)
                {
                    IOSSupportHelper.UpdateIOSPodDependencies(
                        arcoreiOSEnabled && keyvalue.Value, keyvalue.Key);
                }
            }
        }
Example #5
0
        public override void OnGUI(string searchContext)
        {
            ARCoreExtensionsProjectSettingsGUI.OnGUI(false);

            if (GUI.changed)
            {
                IOSSupportHelper.UpdateIOSScriptingDefineSymbols(
                    ARCoreExtensionsProjectSettings.Instance);
                ARCoreExtensionsProjectSettings.Instance.Save();
            }
        }
Example #6
0
        public void OnPreprocessBuild(BuildReport report)
        {
            if (report.summary.platform == BuildTarget.iOS)
            {
                bool arcoreiOSEnabled =
                    ARCoreExtensionsProjectSettings.Instance.IsIOSSupportEnabled;
                Debug.LogFormat("Building application with ARCore Extensions for AR Foundation " +
                                "iOS Support {0}", arcoreiOSEnabled ? "ENABLED" : "DISABLED");

                IOSSupportHelper.SetARCoreIOSSupportEnabled(arcoreiOSEnabled);
            }
        }
Example #7
0
        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)
            {
                // Draw text field for Android Cloud Anchor API Key.
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(s_GroupLabelIndent);
                EditorGUILayout.LabelField(Android, GUILayout.Width(s_GroupFieldIndent));
                ARCoreExtensionsProjectSettings.Instance.AndroidCloudServicesApiKey =
                    EditorGUILayout.TextField(
                        ARCoreExtensionsProjectSettings.Instance.AndroidCloudServicesApiKey);
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);

                // Draw text field for iOS Cloud Anchor API Key.
                if (newIOSEnabled)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(s_GroupLabelIndent);
                    EditorGUILayout.LabelField(IOS, GUILayout.Width(s_GroupFieldIndent));
                    ARCoreExtensionsProjectSettings.Instance.IOSCloudServicesApiKey =
                        EditorGUILayout.TextField(
                            ARCoreExtensionsProjectSettings.Instance.IOSCloudServicesApiKey);
                    EditorGUILayout.EndHorizontal();
                    GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
                }
                else
                {
                    ARCoreExtensionsProjectSettings.Instance.IOSCloudServicesApiKey = string.Empty;
                }
            }

            if (GUI.changed)
            {
                if (newIOSEnabled != ARCoreExtensionsProjectSettings.Instance.IsIOSSupportEnabled)
                {
                    ARCoreExtensionsProjectSettings.Instance.IsIOSSupportEnabled = newIOSEnabled;
                    IOSSupportHelper.SetARCoreIOSSupportEnabled(newIOSEnabled);
                }

                ARCoreExtensionsProjectSettings.Instance.Save();
            }
        }
 public static void OnPostprocessBuild(
     UnityEditor.BuildTarget target, string pathToBuiltProject)
 {
     if (target == UnityEditor.BuildTarget.Android)
     {
         Debug.Log("ARCoreExtensions: Cleaning up Android library dependencies.");
         string folderPath =
             AssetDatabase.GUIDToAssetPath(_buildResourceFolderGUID) +
             _dependenciesDirectory;
         Directory.Delete(folderPath, true);
         AssetDatabase.Refresh();
         AndroidDependenciesHelper.DoPlayServicesResolve();
     }
     else if (target == UnityEditor.BuildTarget.iOS)
     {
         foreach (string enabledTemplateFile in _enabledIOSTemplate)
         {
             Debug.LogFormat("ARCoreExtensions: Cleaning up {0} in PostprocessBuild.",
                             enabledTemplateFile);
             IOSSupportHelper.UpdateIOSPodDependencies(false, enabledTemplateFile);
         }
     }
 }
 private static void AddEarthDependencyOnIos(bool enabled)
 {
     Debug.LogFormat("ARCoreExtensions: {0} Earth Cloud Anchor dependencies.",
                     enabled ? "Adding" : "Removing");
     IOSSupportHelper.UpdateIOSPodDependencies(enabled, _locationIosDependencyFileName);
 }