From eebb60c30b2539e9be840dfad6a3697c73a7ada6 Mon Sep 17 00:00:00 2001 From: client_Wu Xijin <364452445@qq.com> Date: 星期一, 13 八月 2018 13:42:14 +0800 Subject: [PATCH] 更新打包代码。 --- Assets/Editor/Tool/ClientPackage.cs | 75 +++++++++++++++++++++---------------- 1 files changed, 42 insertions(+), 33 deletions(-) diff --git a/Assets/Editor/Tool/ClientPackage.cs b/Assets/Editor/Tool/ClientPackage.cs index 5eb033b..a7a9e9a 100644 --- a/Assets/Editor/Tool/ClientPackage.cs +++ b/Assets/Editor/Tool/ClientPackage.cs @@ -13,21 +13,19 @@ public static readonly string versionsFilePath = Application.dataPath + Path.DirectorySeparatorChar + "Editor/VersionConfigs/Versions.txt"; public static readonly string[] baseLevels = new string[] { "Assets/Resources/Scenes/Launch.unity", "Assets/Resources/Scenes/Empty.unity" }; - public static string SDK_PLUGIN_PROJECT - { + public static string SDK_PLUGIN_PROJECT { get { return LocalSave.GetString("SDK_PROJECT_PATH"); } set { LocalSave.SetString("SDK_PROJECT_PATH", value); } } static string ANDROID_PLUGIN_PATH = Application.dataPath + "/Plugins/Android"; - static int packageIndex - { + static int packageIndex { get { return LocalSave.GetInt("ClientPackageIndex", 1); } set { LocalSave.SetInt("ClientPackageIndex", value); } } - public static void BuildPublishers ( string _sdkPath, string _assetBundlePath, string _output, string _publisherString, bool _development, bool _replace) + public static void BuildPublishers(string _sdkPath, string _assetBundlePath, string _output, string _publisherString, bool _development, bool _replace) { var publisherIds = new List<string>(); var tempStrings = _publisherString.Split(StringUtility.splitSeparator, StringSplitOptions.RemoveEmptyEntries); @@ -95,7 +93,7 @@ for (int i = 0; i < smallPackages.Count; i++) { #if UNITY_ANDROID - BuildApk(_sdkPath,_output, smallPackages[i], _development); + BuildApk(_sdkPath, _output, smallPackages[i], _development); #elif UNITY_IOS BuildIpa(smallPackages[i], _replace); #endif @@ -277,36 +275,47 @@ private static void PreBuild(string _publisher) { - var newVersionConfigPath = StringUtility.Contact("Assets/Resources/ScriptableObject/Config/VersionConfig", ".asset"); - var versionName = string.Empty; - var fromVersionConfig = GetVersionConfig(_publisher, out versionName); - var newVersionConfig = ScriptableObject.CreateInstance<VersionConfig>(); - if (File.Exists(newVersionConfigPath)) + try { - AssetDatabase.DeleteAsset(newVersionConfigPath); + var newVersionConfigPath = StringUtility.Contact("Assets/Resources/ScriptableObject/Config/VersionConfig", ".asset"); + var versionName = string.Empty; + var fromVersionConfig = GetVersionConfig(_publisher, out versionName); + var newVersionConfig = ScriptableObject.CreateInstance<VersionConfig>(); + if (File.Exists(newVersionConfigPath)) + { + AssetDatabase.DeleteAsset(newVersionConfigPath); + } + + VersionConfig.Copy(fromVersionConfig, newVersionConfig); + newVersionConfig.buildTime = DateTime.Now.ToString("yy/MM/dd--HH:mm"); + newVersionConfig.buildIndex = packageIndex; + + AssetDatabase.CreateAsset(newVersionConfig, newVersionConfigPath); + EditorUtility.SetDirty(newVersionConfig); + + SetIconAndSplashImage(versionName); + + PlayerSettings.companyName = "TheSecondWorld"; + PlayerSettings.productName = newVersionConfig.productName; + PlayerSettings.applicationIdentifier = newVersionConfig.bundleIdentifier; + PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation; + PlayerSettings.allowedAutorotateToLandscapeLeft = true; + PlayerSettings.allowedAutorotateToLandscapeRight = true; + PlayerSettings.allowedAutorotateToPortrait = false; + PlayerSettings.allowedAutorotateToPortraitUpsideDown = false; + PlayerSettings.bundleVersion = newVersionConfig.version; + + } + catch (Exception ex) + { + Debug.Log(ex); + } + finally + { + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); } - VersionConfig.Copy(fromVersionConfig, newVersionConfig); - newVersionConfig.buildTime = DateTime.Now.ToString("yy/MM/dd--HH:mm"); - newVersionConfig.buildIndex = packageIndex; - - AssetDatabase.CreateAsset(newVersionConfig, newVersionConfigPath); - EditorUtility.SetDirty(newVersionConfig); - - SetIconAndSplashImage(versionName); - - PlayerSettings.companyName = "TheSecondWorld"; - PlayerSettings.productName = newVersionConfig.productName; - PlayerSettings.applicationIdentifier = newVersionConfig.bundleIdentifier; - PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation; - PlayerSettings.allowedAutorotateToLandscapeLeft = true; - PlayerSettings.allowedAutorotateToLandscapeRight = true; - PlayerSettings.allowedAutorotateToPortrait = false; - PlayerSettings.allowedAutorotateToPortraitUpsideDown = false; - PlayerSettings.bundleVersion = newVersionConfig.version; - - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); } static VersionConfig GetVersionConfig(string _publisher, out string _versionName) -- Gitblit v1.8.0