| | |
| | | using System.IO;
|
| | | using System.Text.RegularExpressions;
|
| | | using System.Text;
|
| | | using TableConfig;
|
| | |
|
| | | using Beebyte.Obfuscator;
|
| | |
|
| | | public class ClientPackage
|
| | |
| | |
|
| | | public static string auditOutTime = string.Empty;
|
| | |
|
| | | 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); }
|
| | | }
|
| | |
|
| | | public static bool obfuscatorEnabled {
|
| | | public static bool obfuscatorEnabled
|
| | | {
|
| | | get { return LocalSave.GetBool("obfuscatorEnabled", false); }
|
| | | set { LocalSave.SetBool("obfuscatorEnabled", value); }
|
| | | }
|
| | |
|
| | | public static int AssetPrior {
|
| | | public static int AssetPrior
|
| | | {
|
| | | get { return LocalSave.GetInt("HalfAssetPrior", 1); }
|
| | | set { LocalSave.SetInt("HalfAssetPrior", value); }
|
| | | }
|
| | |
| | | static string ANDROID_PLUGIN_PATH = Application.dataPath + "/Plugins/Android";
|
| | | static string iOS_PLUGIN_PATH = Application.dataPath + "/Plugins/iOS";
|
| | |
|
| | | /// <summary>
|
| | | /// 打包
|
| | | /// </summary>
|
| | | /// <param name="_sdkPath">整合sdk路径</param>
|
| | | /// <param name="_assetBundlePath">_assetBundle的资源路径,默认在项目目录下的 AssetBundles/android</param>
|
| | | /// <param name="_output">打包完成后的输出路径</param>
|
| | | /// <param name="_publisherString">渠道id,可打多个包,用|分割</param>
|
| | | /// <param name="_buildIndex">打包序序号,用于标识名称</param>
|
| | | /// <param name="_development">是否为开发版</param>
|
| | | /// <param name="_replace">ios打包导出xcode工程模式,Append和Replace</param>
|
| | | public static void BuildPublishers(string _sdkPath, string _assetBundlePath, string _output, string _publisherString, int _buildIndex, bool _development, bool _replace)
|
| | | {
|
| | | var publisherIds = new List<string>();
|
| | |
| | | if (file.FullName.Contains("Contact.txt")
|
| | | || file.FullName.Contains("HelpInfo.txt")
|
| | | || file.FullName.Contains("PriorBundle.txt")
|
| | | || file.FullName.Contains("PriorLanguage.txt"))
|
| | | || file.FullName.Contains("PriorLanguage.txt")
|
| | | || file.FullName.Contains("ApkUpdateUrl.txt")
|
| | | || file.FullName.Contains("InitialFunction.txt"))
|
| | | {
|
| | | builtInFiles.Add(file);
|
| | | continue;
|
| | |
| | | var completeCount = 0;
|
| | | foreach (var item in builtInFiles)
|
| | | {
|
| | | var directory = Path.GetDirectoryName(item.FullName);
|
| | | if (!Directory.Exists(directory))
|
| | | {
|
| | | Directory.CreateDirectory(directory);
|
| | | }
|
| | |
|
| | | var relativePath = FileExtersion.GetFileRelativePath(_assetBundlePath, item.FullName);
|
| | | var to = StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, relativePath);
|
| | | #if UNITY_ANDROID
|
| | | var extension = Path.GetExtension(item.FullName);
|
| | | if (extension == ".meta")
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | to = to + ".7z";
|
| | | SevenZipUtility.Compress(item.FullName, to);
|
| | | UnityEditor.EditorUtility.DisplayProgressBar("正在压缩资源", item.Name, (float)completeCount / totalCount);
|
| | | #elif UNITY_IOS
|
| | | File.Copy(item.FullName,to,true);
|
| | | #endif
|
| | | var relativePath = FileExtersion.GetFileRelativePath(_assetBundlePath, item.FullName);
|
| | | var to = StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, relativePath);
|
| | | var directory = Path.GetDirectoryName(to);
|
| | | if (!Directory.Exists(directory))
|
| | | {
|
| | | Directory.CreateDirectory(directory);
|
| | | }
|
| | |
|
| | | File.Copy(item.FullName, to, true);
|
| | | completeCount++;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | if (halfPackages.Count > 0)
|
| | | {
|
| | | Config.Instance.LoadPriorBundleConfig();
|
| | | PriorBundleConfig.Init(true);
|
| | |
|
| | | var fromFiles = new List<FileInfo>();
|
| | | FileExtersion.GetAllDirectoryFileInfos(_assetBundlePath, fromFiles);
|
| | |
| | | var completeCount = 0;
|
| | | foreach (var item in fromFiles)
|
| | | {
|
| | | var directory = Path.GetDirectoryName(item.FullName);
|
| | | var relativePath = FileExtersion.GetFileRelativePath(_assetBundlePath, item.FullName);
|
| | | var to = StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, relativePath);
|
| | | var directory = Path.GetDirectoryName(to);
|
| | | if (!Directory.Exists(directory))
|
| | | {
|
| | | Directory.CreateDirectory(directory);
|
| | | }
|
| | |
|
| | | var relativePath = FileExtersion.GetFileRelativePath(_assetBundlePath, item.FullName);
|
| | | var to = StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, relativePath);
|
| | | #if UNITY_ANDROID
|
| | | var extension = Path.GetExtension(item.FullName);
|
| | | if (extension == ".meta")
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | to = to + ".7z";
|
| | | SevenZipUtility.Compress(item.FullName, to);
|
| | | UnityEditor.EditorUtility.DisplayProgressBar("正在压缩资源", item.Name, (float)completeCount / totalCount);
|
| | | #elif UNITY_IOS
|
| | | File.Copy(item.FullName,to,true);
|
| | | #endif
|
| | |
|
| | | File.Copy(item.FullName, to, true);
|
| | | completeCount++;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | if (bigPackages.Count > 0)
|
| | | {
|
| | | FileExtersion.DirectoryCopy(_assetBundlePath, ResourcesPath.Instance.StreamingAssetPath);
|
| | | var fromFiles = new List<FileInfo>();
|
| | | FileExtersion.GetAllDirectoryFileInfos(_assetBundlePath, fromFiles);
|
| | |
|
| | | var totalCount = fromFiles.Count;
|
| | | var completeCount = 0;
|
| | | foreach (var item in fromFiles)
|
| | | {
|
| | | var relativePath = FileExtersion.GetFileRelativePath(_assetBundlePath, item.FullName);
|
| | | var to = StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, relativePath);
|
| | | var directory = Path.GetDirectoryName(to);
|
| | | if (!Directory.Exists(directory))
|
| | | {
|
| | | Directory.CreateDirectory(directory);
|
| | | }
|
| | |
|
| | | var extension = Path.GetExtension(item.FullName);
|
| | | if (extension == ".meta")
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | File.Copy(item.FullName, to, true);
|
| | | completeCount++;
|
| | | }
|
| | |
|
| | | for (int i = 0; i < bigPackages.Count; i++)
|
| | | {
|
| | | #if UNITY_ANDROID
|
| | |
| | | // 针对某一些打包的特殊性, 这里特指依赖的第三方库含有资源的问题
|
| | | // 这里对有这种特型的渠道的sdk在打包的时候差异化gradle文件
|
| | | // 更名原有文件
|
| | | string _gradleTemplateUrl = EditorApplication.applicationContentsPath + "/PlaybackEngines/AndroidPlayer/Tools/GradleTemplates/";
|
| | | string _gradleFileUrl = _gradleTemplateUrl + "mainTemplate.gradle";
|
| | | string _diffGradleFileUrl = StringUtility.Contact(_sdkPath, "/GradleDiff/", versionConfig.appId, "/mainTemplate.gradle");
|
| | | FileInfo _fileInfo = new FileInfo(_diffGradleFileUrl);
|
| | | // string _gradleTemplateUrl = EditorApplication.applicationContentsPath + "/PlaybackEngines/AndroidPlayer/Tools/GradleTemplates/";
|
| | | // string _gradleFileUrl = _gradleTemplateUrl + "mainTemplate.gradle";
|
| | | // string _diffGradleFileUrl = StringUtility.Contact(_sdkPath, "/GradleDiff/", versionConfig.appId, "/mainTemplate.gradle");
|
| | | // FileInfo _fileInfo = new FileInfo(_diffGradleFileUrl);
|
| | |
|
| | | if (!_fileInfo.Exists)
|
| | | {
|
| | | EditorUtility.DisplayDialog("警告", "Gradle模式需要配置差异文件,但是没有找到该文件: " + _diffGradleFileUrl, "@Hale");
|
| | | return;
|
| | | }
|
| | | // if (!_fileInfo.Exists)
|
| | | // {
|
| | | // EditorUtility.DisplayDialog("警告", "Gradle模式需要配置差异文件,但是没有找到该文件: " + _diffGradleFileUrl, "@Hale");
|
| | | // return;
|
| | | // }
|
| | |
|
| | | _fileInfo.CopyTo(_gradleFileUrl, true);
|
| | | // _fileInfo.CopyTo(_gradleFileUrl, true);
|
| | |
|
| | | // 移动配置文件至打包工作目录中
|
| | |
|
| | | PlayerSettings.Android.keystoreName = Application.dataPath + "/Editor/Keystore/" + versionConfig.keystoreFileName + ".keystore";
|
| | | var keystorePath = Application.dataPath + "/Editor/Keystore/" + versionConfig.keystoreFileName + ".keystore";
|
| | | if (!File.Exists(keystorePath))
|
| | | {
|
| | | Debug.LogError("签名文件不存在");
|
| | | return;
|
| | | }
|
| | | PlayerSettings.Android.keystoreName = keystorePath;
|
| | | PlayerSettings.Android.keystorePass = versionConfig.keystorePassword;
|
| | | PlayerSettings.Android.keyaliasName = versionConfig.keystoreAlias;
|
| | | PlayerSettings.Android.keyaliasPass = versionConfig.keystoreAliasPassword;
|
| | | PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevel22;
|
| | | // PlayerSettings.Android.targetSdkVersion = AndroidSdkVersions.AndroidApiLevel22;
|
| | | PlayerSettings.Android.bundleVersionCode = VersionConfig.GetVersionNumber(versionConfig.version);
|
| | |
|
| | | PlayerSettings.enableInternalProfiler = _development;
|
| | |
| | | Directory.Delete(iOS_PLUGIN_PATH, true);
|
| | | }
|
| | |
|
| | | if (!versionConfig.appId.Equals("test"))
|
| | | {
|
| | | FileExtersion.DirectoryCopy(StringUtility.Contact(_sdkPath, "/ChannelDiff/iOS/", versionConfig.appId), iOS_PLUGIN_PATH);
|
| | | }
|
| | | // if (!versionConfig.appId.Equals("test"))
|
| | | // {
|
| | | FileExtersion.DirectoryCopy(StringUtility.Contact(_sdkPath, "/ChannelDiff/iOS/", versionConfig.appId), iOS_PLUGIN_PATH);
|
| | | // }
|
| | |
|
| | | DateTime outTime;
|
| | | var correct = DateTime.TryParse(auditOutTime, out outTime);
|
| | | var directory = Application.dataPath + Path.DirectorySeparatorChar + "Resources/Config";
|
| | | if (!Directory.Exists(directory))
|
| | | {
|
| | | Directory.CreateDirectory(directory);
|
| | | }
|
| | | File.WriteAllText(Application.dataPath + Path.DirectorySeparatorChar + "Resources/Config/AuditTime.txt", correct ? auditOutTime : "");
|
| | | |
| | |
|
| | | var option = AssetDatabase.LoadAssetAtPath<Options>("Assets/Editor/Beebyte/Obfuscator/ObfuscatorOptions.asset");
|
| | | if (option!=null)
|
| | | if (option != null)
|
| | | {
|
| | | option.enabled = obfuscatorEnabled;
|
| | | EditorUtility.SetDirty(option);
|
| | | }
|
| | | |
| | |
|
| | | AssetDatabase.SaveAssets();
|
| | | AssetDatabase.Refresh();
|
| | | PlayerSettings.iOS.buildNumber = VersionConfig.Get().buildIndex.ToString();
|
| | |
| | | {
|
| | | try
|
| | | {
|
| | | var newVersionConfigPath = StringUtility.Contact("Assets/Resources/ScriptableObject/Config/VersionConfig", ".asset");
|
| | | var newVersionConfigPath = StringUtility.Contact("Assets/Resources/VersionConfig", ".asset");
|
| | | var versionName = string.Empty;
|
| | | var fromVersionConfig = GetVersionConfig(_publisher, out versionName);
|
| | | var newVersionConfig = ScriptableObject.CreateInstance<VersionConfig>();
|
| | |
| | | newVersionConfig.buildTime = DateTime.Now.ToString("yy/MM/dd--HH:mm");
|
| | | newVersionConfig.buildIndex = _buildIndex;
|
| | |
|
| | | if (File.Exists(Application.dataPath + "/Resources/Game.txt"))
|
| | | {
|
| | | File.Delete(Application.dataPath + "/Resources/Game.txt");
|
| | | }
|
| | |
|
| | | File.WriteAllText(Application.dataPath + "/Resources/Game.txt", GetGameId(_publisher));
|
| | |
|
| | | AssetDatabase.CreateAsset(newVersionConfig, newVersionConfigPath);
|
| | | EditorUtility.SetDirty(newVersionConfig);
|
| | |
|
| | | SetIconAndSplashImage(versionName);
|
| | | //SetCreateRoleAnimation();
|
| | |
|
| | | PlayerSettings.companyName = "TheSecondWorld";
|
| | | PlayerSettings.productName = newVersionConfig.productName;
|
| | |
| | | PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
|
| | | PlayerSettings.bundleVersion = VersionConfig.GetVersionNumber(newVersionConfig.version).ToString();
|
| | |
|
| | | CSObjectWrapEditor.Generator.ClearAll();
|
| | | CSObjectWrapEditor.Generator.GenAll();
|
| | | if (GetBuildTarget() == BuildTargetGroup.Android)
|
| | | {
|
| | | CSObjectWrapEditor.Generator.ClearAll();
|
| | | CSObjectWrapEditor.Generator.GenAll();
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | static string GetGameId(string _publisher)
|
| | | {
|
| | | var lines = File.ReadAllLines(versionsFilePath);
|
| | | for (int i = 2; i < lines.Length; i++)
|
| | | {
|
| | | var line = lines[i];
|
| | | var lineStrings = line.Split('\t');
|
| | | if (lineStrings[0] == _publisher)
|
| | | {
|
| | | return lineStrings[7];
|
| | | }
|
| | | }
|
| | |
|
| | | return "xbqy";
|
| | | }
|
| | |
|
| | | static void SetIconAndSplashImage(string _versionName)
|
| | | {
|
| | | var buildTarget = GetBuildTarget();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public static void SetCreateRoleAnimation()
|
| | | {
|
| | | var from = "Assets/Editor/Video/CreateRoleMovie.mp4";
|
| | | var to = "Assets/StreamingAssets/CreateRoleMovie.mp4";
|
| | |
|
| | | if (!Directory.Exists(Application.dataPath + "StreamingAssets"))
|
| | | {
|
| | | Directory.CreateDirectory(Application.dataPath + "StreamingAssets");
|
| | | }
|
| | |
|
| | | if (AssetDatabase.LoadAssetAtPath<UnityEngine.Video.VideoClip>(to) == null)
|
| | | {
|
| | | AssetDatabase.CopyAsset(from, to);
|
| | | }
|
| | | }
|
| | |
|
| | | static BuildTargetGroup GetBuildTarget()
|
| | | {
|
| | | #if UNITY_ANDROID
|