For a project at work I needed a way to swap the splash screen, app icon and package name in order to build 8 different themed apps. So here is a way to do it. This script creates a menu entry where you can simply select the specific build and change almost every build setting. Feel free to add any missing qualifier. (UnityEditor.PlayerSettings)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | using UnityEngine; using System.Collections; #if UNITY_EDITOR using UnityEditor; #endif // inspired by http://www.fugutalk.com/?p=6047 public class ChangeBuildSettings : MonoBehaviour { #if UNITY_EDITOR private static string SplashScreen = "Assets/resources/active/SplashScreen.png"; private static string Icon = "Assets/resources/active/Icon.png"; private static string Background = "Assets/resources/active/Background.png"; private static string resourcePath = "Resources/"; private static void GeneralSettings() { PlayerSettings.productName = "Random App Name"; PlayerSettings.Android.bundleVersionCode = 1; PlayerSettings.bundleVersion = "1.0"; PlayerSettings.companyName = "Random Company"; PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android,"Default"); PlayerSettings.strippingLevel = StrippingLevel.UseMicroMSCorlib; } private static void SwapAsset(string source, string target) { Debug.Log("Using: " + source); if (System.IO.File.Exists(target)) { Debug.Log("Updating: " + target); FileUtil.ReplaceFile(source, target); } else { Debug.Log("Creating: " + target); FileUtil.CopyFileOrDirectory(source, target); } } private static void ChangeFontColor(Color color) { foreach (var font in GameObject.FindGameObjectsWithTag ("GuiText")) { Debug.Log("Changing color for " + font.name); font.guiText.color = color; } } [MenuItem ("Custom Build Settings/Default")] public static void PuzzleSwapDefault() { GeneralSettings (); //PlayerSettings.productName = "Random App Name: Default"; PlayerSettings.bundleIdentifier = "com.random.randomapp.default"; SwapAsset (resourcePath + "default/Loading-Screen.png", SplashScreen); SwapAsset (resourcePath + "default/Background.png", Background); SwapAsset (resourcePath + "default/AppIcon.png", Icon); ChangeFontColor (Color.black); AssetDatabase.Refresh(); } [MenuItem ("Custom Build Settings/Christmas Edition")] public static void PuzzleSwapClouds() { GeneralSettings (); //PlayerSettings.productName = "Random App: Xmas Special"; PlayerSettings.bundleIdentifier = "com.random.randomapp.xmas"; // not necessary, except you wanna publish the same app on the market SwapAsset (resourcePath + "xmas/Loading-Screen.png", SplashScreen); SwapAsset (resourcePath + "xmas/Background.png", Background); SwapAsset (resourcePath + "xmasAppIcon.png", Icon); ChangeFontColor (Color.black); AssetDatabase.Refresh(); } #endif } |