少年修仙传客户端基础资源
lwb
2020-11-17 4bafd190b3fadd23dc222285a6a7cc97edbcf921
Assets/Editor/Tool/ClientPackage.cs
@@ -16,17 +16,20 @@
    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); }
    }
@@ -34,6 +37,16 @@
    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>();
@@ -117,7 +130,8 @@
                    || 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;
@@ -144,7 +158,7 @@
                    Directory.CreateDirectory(directory);
                }
                File.Copy(item.FullName,to,true);
                File.Copy(item.FullName, to, true);
                completeCount++;
            }
@@ -365,26 +379,31 @@
        // 针对某一些打包的特殊性, 这里特指依赖的第三方库含有资源的问题
        // 这里对有这种特型的渠道的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;
@@ -433,10 +452,10 @@
            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);
@@ -446,14 +465,14 @@
            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();
@@ -487,11 +506,18 @@
            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();
            //SetCreateRoleAnimation();
            PlayerSettings.companyName = "TheSecondWorld";
            PlayerSettings.productName = newVersionConfig.productName;
@@ -503,8 +529,11 @@
            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)
        {
@@ -539,6 +568,22 @@
        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();