private static bool IsCloudAnchorModeEnabled()
        {
            foreach (ARCoreSessionConfig config in
                     AndroidDependenciesHelper.GetAllSessionConfigs().Keys)
            {
                if (config.CloudAnchorMode != CloudAnchorMode.Disabled)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        private static CloudAnchorMode GetActiveCloudAnchorMode()
        {
            CloudAnchorMode mode = CloudAnchorMode.Disabled;

            foreach (ARCoreSessionConfig config in
                     AndroidDependenciesHelper.GetAllSessionConfigs().Keys)
            {
                if (config.CloudAnchorMode > mode)
                {
                    mode = config.CloudAnchorMode;
                }
            }

            return(mode);
        }
예제 #3
0
        private void PreprocessAndroidBuild()
        {
            // This function causes build error in 2020.2 if the current directory is changed.
            // So do the check first here.
            CheckCompatibilityWithAllSesssionConfigs(
                ARCoreProjectSettings.Instance, AndroidDependenciesHelper.GetAllSessionConfigs());

            string cachedCurrentDirectory = Directory.GetCurrentDirectory();
            string pluginsFolderPath      = Path.Combine(cachedCurrentDirectory,
                                                         AssetDatabase.GUIDToAssetPath(_pluginsFolderGuid));
            string customizedManifestAarPath =
                Path.Combine(pluginsFolderPath, "customized_manifest.aar");

            string jarPath = Path.Combine(AndroidDependenciesHelper.GetJdkPath(), "bin/jar");

            var tempDirectoryPath =
                Path.Combine(cachedCurrentDirectory, FileUtil.GetUniqueTempPathInProject());

            try
            {
                // Move to a temp directory.
                Directory.CreateDirectory(tempDirectoryPath);
                Directory.SetCurrentDirectory(tempDirectoryPath);

                CreateClassesJar(jarPath, tempDirectoryPath);

                XDocument customizedManifest =
                    GenerateCustomizedAndroidManifest(ARCoreProjectSettings.Instance);
                var manifestPath = Path.Combine(tempDirectoryPath, "AndroidManifest.xml");
                customizedManifest.Save(manifestPath);

                // Compress the new AAR.
                var fileListBuilder = new StringBuilder();
                foreach (var filePath in Directory.GetFiles(tempDirectoryPath))
                {
                    fileListBuilder.AppendFormat(" {0}", Path.GetFileName(filePath));
                }

                string command = string.Format(
                    "cf customized_manifest.aar {0}", fileListBuilder.ToString());

                string output;
                string errors;
                ShellHelper.RunCommand(jarPath, command, out output, out errors);

                if (!string.IsNullOrEmpty(errors))
                {
                    throw new BuildFailedException(
                              string.Format(
                                  "Error creating aar for manifest: {0}", errors));
                }

                File.Copy(Path.Combine(tempDirectoryPath, "customized_manifest.aar"),
                          customizedManifestAarPath, true);
            }
            finally
            {
                // Cleanup.
                Directory.SetCurrentDirectory(cachedCurrentDirectory);
                Directory.Delete(tempDirectoryPath, true);

                AssetDatabase.Refresh();
            }

            AssetHelper.GetPluginImporterByName("customized_manifest.aar")
            .SetCompatibleWithPlatform(BuildTarget.Android, true);
        }