Exemple #1
0
        /// <summary>
        /// Generates the android manifest.
        /// </summary>
        public static void GenerateAndroidManifest()
        {
            string destFilename = GPGSUtil.SlashesToPlatformSeparator(ManifestPath);

            // Generate AndroidManifest.xml
            string manifestBody = GPGSUtil.ReadEditorTemplate("template-AndroidManifest");

            Dictionary <string, string> overrideValues =
                new Dictionary <string, string>();

            foreach (KeyValuePair <string, string> ent in replacements)
            {
                string value =
                    GPGSProjectSettings.Instance.Get(ent.Value, overrideValues);
                manifestBody = manifestBody.Replace(ent.Key, value);
            }

            GPGSUtil.WriteFile(destFilename, manifestBody);
            GPGSUtil.UpdateGameInfo();
        }
        /// <summary>
        /// Generates the android manifest.
        /// </summary>
        public static void GenerateAndroidManifest()
        {
            var destFilename = GPGSUtil.SlashesToPlatformSeparator(
                "Assets/Plugins/Android/MainLibProj/AndroidManifest.xml");

            // Generate AndroidManifest.xml
            var manifestBody = GPGSUtil.ReadEditorTemplate("template-AndroidManifest");

            var overrideValues =
                new Dictionary <string, string>();

            foreach (var ent in replacements)
            {
                var value =
                    GPGSProjectSettings.Instance.Get(ent.Value, overrideValues);
                manifestBody = manifestBody.Replace(ent.Key, value);
            }

            GPGSUtil.WriteFile(destFilename, manifestBody);
            GPGSUtil.UpdateGameInfo();
        }
        /// <summary>
        /// Generates the android manifest.
        /// </summary>
        public static void GenerateAndroidManifest()
        {
            string destFilename = ManifestPath;

            // Generate AndroidManifest.xml
            string manifestBody = GPGSUtil.ReadEditorTemplate("template-AndroidManifest");

            Dictionary <string, string> overrideValues =
                new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(GPGSProjectSettings.Instance.Get(SERVICEIDKEY)))
            {
                overrideValues[NEARBY_PERMISSIONS_PLACEHOLDER] =
                    "        <!-- Required for Nearby Connections -->\n" +
                    "        <uses-permission android:name=\"android.permission.BLUETOOTH\" />\n" +
                    "        <uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" />\n" +
                    "        <uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />\n" +
                    "        <uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\" />\n" +
                    "        <uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />\n";
                overrideValues[SERVICEID_ELEMENT_PLACEHOLDER] =
                    "             <!-- Required for Nearby Connections API -->\n" +
                    "             <meta-data android:name=\"com.google.android.gms.nearby.connection.SERVICE_ID\"\n" +
                    "                  android:value=\"__NEARBY_SERVICE_ID__\" />\n";
            }
            else
            {
                overrideValues[NEARBY_PERMISSIONS_PLACEHOLDER] = "";
                overrideValues[SERVICEID_ELEMENT_PLACEHOLDER]  = "";
            }

            foreach (KeyValuePair <string, string> ent in replacements)
            {
                string value =
                    GPGSProjectSettings.Instance.Get(ent.Value, overrideValues);
                manifestBody = manifestBody.Replace(ent.Key, value);
            }

            GPGSUtil.WriteFile(destFilename, manifestBody);
            GPGSUtil.UpdateGameInfo();
        }
Exemple #4
0
        /// <summary>
        /// Writes the resource identifiers file.  This file contains the
        /// resource ids copied (downloaded?) from the play game app console.
        /// </summary>
        /// <param name="classDirectory">Class directory.</param>
        /// <param name="className">Class name.</param>
        /// <param name="resourceKeys">Resource keys.</param>
        public static void WriteResourceIds(string classDirectory, string className, Hashtable resourceKeys)
        {
            string constantsValues = string.Empty;

            string[] parts   = className.Split('.');
            string   dirName = classDirectory;

            if (string.IsNullOrEmpty(dirName))
            {
                dirName = "Assets";
            }

            string nameSpace = string.Empty;

            for (int i = 0; i < parts.Length - 1; i++)
            {
                dirName += "/" + parts[i];
                if (nameSpace != string.Empty)
                {
                    nameSpace += ".";
                }

                nameSpace += parts[i];
            }

            EnsureDirExists(dirName);
            foreach (DictionaryEntry ent in resourceKeys)
            {
                string key = MakeIdentifier((string)ent.Key);
                constantsValues += "        public const string " +
                                   key + " = \"" + ent.Value + "\"; // <GPGSID>\n";
            }

            string fileBody = GPGSUtil.ReadEditorTemplate("template-Constants");

            if (nameSpace != string.Empty)
            {
                fileBody = fileBody.Replace(
                    NAMESPACESTARTPLACEHOLDER,
                    "namespace " + nameSpace + "\n{");
            }
            else
            {
                fileBody = fileBody.Replace(NAMESPACESTARTPLACEHOLDER, string.Empty);
            }

            fileBody = fileBody.Replace(CLASSNAMEPLACEHOLDER, parts[parts.Length - 1]);
            fileBody = fileBody.Replace(CONSTANTSPLACEHOLDER, constantsValues);
            if (nameSpace != string.Empty)
            {
                fileBody = fileBody.Replace(
                    NAMESPACEENDPLACEHOLDER,
                    "}");
            }
            else
            {
                fileBody = fileBody.Replace(NAMESPACEENDPLACEHOLDER, string.Empty);
            }

            WriteFile(Path.Combine(dirName, parts[parts.Length - 1] + ".cs"), fileBody);
        }