Esempio n. 1
0
        public static bool DoSetup(string appID)
        {
            var projAM = GPGSUtil.SlashesToPlatformSeparator(CloudOncePaths.GooglePlayLib + "/AndroidManifest.xml");

            // check for valid app id
            if (!GPGSUtil.LooksLikeValidAppId(appID))
            {
                GPGSUtil.Alert(GPGSStrings.Setup.AppIdError);
                return(false);
            }

            // Generate AndroidManifest.xml
            var manifestBody = GPGSUtil.ReadFile(c_manifestTemplate);

            manifestBody = manifestBody.Replace(c_appIdPlaceholder, appID);
#if UNITY_ANDROID
            manifestBody = manifestBody.Replace(c_pluginVersionPlaceholder, PluginVersion.VersionString);
#endif
            manifestBody = manifestBody.Replace(c_serviceIdPlaceholder, string.Empty);
            GPGSUtil.WriteFile(projAM, manifestBody);

            // Resolve dependencies
#if UNITY_ANDROID
            PlayServicesResolver.Resolver.DoResolution(
                GPGSDependencies.svcSupport,
                CloudOncePaths.Android,
                PlayServicesResolver.HandleOverwriteConfirmation);
#endif

            // refresh assets, and we're done
            AssetDatabase.Refresh();
            return(EditorUtility.DisplayDialog(GPGSStrings.Success, GPGSStrings.AndroidSetup.SetupComplete, GPGSStrings.Ok));
        }
        public static bool DoSetup(string appID)
        {
            // check for valid app id
            if (!GPGSUtil.LooksLikeValidAppId(appID))
            {
                GPGSUtil.Alert(GPGSStrings.Setup.AppIdError);
                return(false);
            }

            if (!GPGSUtil.HasAndroidSdk())
            {
                EditorUtility.DisplayDialog(
                    GPGSStrings.AndroidSetup.SdkNotFound,
                    GPGSStrings.AndroidSetup.SdkNotFoundBlurb,
                    GPGSStrings.Ok);
                return(false);
            }

            // Generate AndroidManifest.xml
            var destination  = GPGSUtil.SlashesToPlatformSeparator(CloudOncePaths.GooglePlayLib + "/AndroidManifest.xml");
            var manifestBody = GPGSUtil.ReadFile(manifestTemplate);

            manifestBody = manifestBody.Replace(appIdPlaceholder, appID);
#if UNITY_ANDROID
            manifestBody = manifestBody.Replace(pluginVersionPlaceholder, PluginVersion.VersionString);
#endif
            manifestBody = manifestBody.Replace(serviceIdPlaceholder, string.Empty);
            GPGSUtil.WriteFile(destination, manifestBody);

            // Resolve dependencies
            Google.VersionHandler.UpdateVersionedAssets(true);
            Google.VersionHandler.Enabled = true;
            AssetDatabase.Refresh();
            Google.VersionHandler.InvokeStaticMethod(
                Google.VersionHandler.FindClass("Google.JarResolver", "GooglePlayServices.PlayServicesResolver"),
                "MenuResolve",
                null);

            // refresh assets, and we're done
            AssetDatabase.Refresh();
            return(EditorUtility.DisplayDialog(GPGSStrings.Success, GPGSStrings.AndroidSetup.SetupComplete, GPGSStrings.Ok));
        }