| | |
| | |
|
| | | 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 bool includeConfig
|
| | | {
|
| | | get { return LocalSave.GetBool("client_pg_includeConfig", false); }
|
| | | set { LocalSave.SetBool("client_pg_includeConfig", value); }
|
| | | }
|
| | |
|
| | | public static int AssetPrior {
|
| | | public static bool includeUI
|
| | | {
|
| | | get { return LocalSave.GetBool("client_pg_includeUI", false); }
|
| | | set { LocalSave.SetBool("client_pg_includeUI", value); }
|
| | | }
|
| | |
|
| | | 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 THE_2TH_WORLD_SDK_PATH = Application.dataPath + "/Plugins/Android/bin";
|
| | | // static string MANIFEST_PATH = Application.dataPath + "/Plugins/Android/AndroidManifest.xml";
|
| | | 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>();
|
| | |
| | | || file.FullName.Contains("HelpInfo.txt")
|
| | | || file.FullName.Contains("PriorBundle.txt")
|
| | | || file.FullName.Contains("PriorLanguage.txt")
|
| | | || file.FullName.Contains("ApkUpdateUrl.txt"))
|
| | | || file.FullName.Contains("ApkUpdateUrl.txt")
|
| | | || file.FullName.Contains("InitialFunction.txt"))
|
| | | {
|
| | | builtInFiles.Add(file);
|
| | | continue;
|
| | | }
|
| | |
|
| | | File.Delete(file.FullName);
|
| | | // File.Delete(file.FullName);
|
| | | }
|
| | |
|
| | | var totalCount = builtInFiles.Count;
|
| | |
| | | foreach (var file in tempFiles)
|
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileName(file.FullName);
|
| | | if (!string.IsNullOrEmpty(extersion))
|
| | | {
|
| | | fileName = fileName.Replace(extersion, "");
|
| | | }
|
| | |
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Mob, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | |
| | | foreach (var file in tempFiles)
|
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileName(file.FullName);
|
| | | if (!string.IsNullOrEmpty(extersion))
|
| | | {
|
| | | fileName = fileName.Replace(extersion, "");
|
| | | }
|
| | |
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Scene, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | |
| | | foreach (var file in tempFiles)
|
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileName(file.FullName);
|
| | | if (!string.IsNullOrEmpty(extersion))
|
| | | {
|
| | | fileName = fileName.Replace(extersion, "");
|
| | | }
|
| | |
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Audio, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | |
| | | foreach (var file in tempFiles)
|
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileName(file.FullName);
|
| | | if (!string.IsNullOrEmpty(extersion))
|
| | | {
|
| | | fileName = fileName.Replace(extersion, "");
|
| | | }
|
| | |
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Effect, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | //剔除视频资源
|
| | | tempFiles.Clear();
|
| | | FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(_assetBundlePath, "/video"), tempFiles);
|
| | | foreach (var file in tempFiles)
|
| | | {
|
| | | var extersion = Path.GetExtension(file.FullName);
|
| | | var fileName = Path.GetFileNameWithoutExtension(file.FullName);
|
| | | var prior = PriorBundleConfig.GetAssetPrior(AssetVersion.AssetCategory.Video, fileName);
|
| | | if (prior > AssetPrior)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | | }
|
| | | }
|
| | |
|
| | | //剔除表资源
|
| | | if (!includeConfig)
|
| | | {
|
| | | tempFiles.Clear();
|
| | | FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(_assetBundlePath, "/config"), tempFiles);
|
| | | foreach (var file in tempFiles)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | | }
|
| | | }
|
| | |
|
| | | //剔除UI资源
|
| | | tempFiles.Clear();
|
| | | FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(_assetBundlePath, "/ui/sprite"), tempFiles);
|
| | | foreach (var file in tempFiles)
|
| | | {
|
| | | var fileName = Path.GetFileName(file.FullName);
|
| | | if (fileName == "loadingbg")
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | | }
|
| | | }
|
| | | if (!includeUI)
|
| | | {
|
| | | tempFiles.Clear();
|
| | | FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(_assetBundlePath, "/ui"), tempFiles);
|
| | | foreach (var file in tempFiles)
|
| | | {
|
| | | excludeFileFullNames.Add(file.FullName);
|
| | | }
|
| | |
| | | {
|
| | | var relativePath = FileExtersion.GetFileRelativePath(_assetBundlePath, item.FullName);
|
| | | var to = StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, relativePath);
|
| | | if (relativePath.StartsWith("patch"))//不包含meta文件和补丁
|
| | | continue;
|
| | |
|
| | | 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++;
|
| | |
| | | {
|
| | | var relativePath = FileExtersion.GetFileRelativePath(_assetBundlePath, item.FullName);
|
| | | var to = StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, relativePath);
|
| | | if (relativePath.StartsWith("patch"))//不包含meta文件和补丁
|
| | | continue;
|
| | |
|
| | | 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++;
|
| | |
| | | public static void BuildApk(string _sdkPath, string _output, string _publisher, int _buildIndex, bool _development)
|
| | | {
|
| | | PreBuild(_publisher, _buildIndex);
|
| | |
|
| | | var auditTimeFile = StringUtility.Contact(Application.dataPath, Path.DirectorySeparatorChar, "Resources/Config/AuditTime.txt");
|
| | | if (File.Exists(auditTimeFile))
|
| | | {
|
| | |
| | | // 针对某一些打包的特殊性, 这里特指依赖的第三方库含有资源的问题
|
| | | // 这里对有这种特型的渠道的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;
|
| | |
|
| | | if (Directory.Exists(ANDROID_PLUGIN_PATH))
|
| | | {
|
| | | Directory.Delete(ANDROID_PLUGIN_PATH, true);
|
| | | }
|
| | | //删除原sdk文件
|
| | | if (Directory.Exists(THE_2TH_WORLD_SDK_PATH))
|
| | | Directory.Delete(THE_2TH_WORLD_SDK_PATH, true);
|
| | | //删除原清单文件
|
| | | // if (File.Exists(MANIFEST_PATH))
|
| | | // File.Delete(MANIFEST_PATH);
|
| | |
|
| | | Debug.LogFormat("执行Android SDK 文件拷贝,from:{0};to:{1}", StringUtility.Contact(_sdkPath, "/Android/release"), ANDROID_PLUGIN_PATH);
|
| | | FileExtersion.DirectoryCopy(StringUtility.Contact(_sdkPath, "/Android/release"), ANDROID_PLUGIN_PATH);
|
| | | FileExtersion.DirectoryCopy(StringUtility.Contact(_sdkPath, "/ChannelDiff/Android/", versionConfig.appId), ANDROID_PLUGIN_PATH);
|
| | | var variant = _development ? "debug" : "release";
|
| | |
|
| | | // var manifestpath = StringUtility.Contact(_sdkPath, "/Channel/Android/", versionConfig.appId, "/AndroidManifest.xml");
|
| | | var channelSdkPath = StringUtility.Contact(_sdkPath, "/Channel/Android/", versionConfig.appId, "/", variant);
|
| | |
|
| | | // if (File.Exists(manifestpath))
|
| | | // {
|
| | | // File.Copy(manifestpath, MANIFEST_PATH);
|
| | | // DebugEx.LogFormat("执行Android 清单文件拷贝,from:{0};to:{1}", manifestpath, MANIFEST_PATH);
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // DebugEx.LogFormat("Android 清单文件不存在,{0}", manifestpath);
|
| | | // // return;
|
| | | // }
|
| | |
|
| | | if (Directory.Exists(channelSdkPath))
|
| | | {
|
| | | FileExtersion.DirectoryCopy(channelSdkPath, THE_2TH_WORLD_SDK_PATH);
|
| | | DebugEx.LogFormat("执行Android 渠道SDK 文件拷贝,from:{0};to:{1}", channelSdkPath, THE_2TH_WORLD_SDK_PATH);
|
| | | }
|
| | | else
|
| | | {
|
| | | DebugEx.LogFormat("Android 渠道SDK文件不存在,{0}", channelSdkPath);
|
| | | return;
|
| | | }
|
| | |
|
| | | var option = AssetDatabase.LoadAssetAtPath<Options>("Assets/Editor/Beebyte/Obfuscator/ObfuscatorOptions.asset");
|
| | | if (option != null)
|
| | |
| | |
|
| | | AssetDatabase.SaveAssets();
|
| | | AssetDatabase.Refresh();
|
| | |
|
| | | IFix.Editor.IFixEditor.InjectAllAssemblys();//对injectAssemblys里的程序集进行注入,然后备份
|
| | |
|
| | | if (_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);
|
| | |
| | | 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();
|
| | | PlayerSettings.iOS.appleDeveloperTeamID = VersionConfig.Get().appleDeveloperTeamID;
|
| | |
|
| | | IFix.Editor.IFixEditor.InjectAllAssemblys();//对injectAssemblys里的程序集进行注入,然后备份
|
| | |
|
| | | if (_replace)
|
| | | {
|
| | |
| | | EditorUtility.SetDirty(newVersionConfig);
|
| | |
|
| | | SetIconAndSplashImage(versionName);
|
| | | SetCreateRoleAnimation();
|
| | | //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)
|
| | | {
|