示例#1
0
    private static void MakeUpdatePackage(string platform, string channel, string version, string cSharp, string script)
    {
        if (platform.Equals("Android"))
        {
            EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);
            EditorUserBuildSettings.androidBuildSubtarget = AndroidBuildSubtarget.ETC2;
        }

        //config读取
        var buildPath       = Path.Combine(Application.dataPath, "../build/");
        var versionPath     = string.Format("../../Public/Version/Cn/{0}/{1}/Game.ver", platform, channel);
        var versionFullPath = Path.Combine(Application.dataPath, versionPath);
        var verInfo         = File.ReadAllText(versionFullPath).Trim();
        var config          = verInfo.Split(',');
        var ver             = config[3];

        if (!string.IsNullOrEmpty(version))
        {
            ver = version;
        }
        ver = ver.Trim().Replace(Environment.NewLine, "");


        //设置updatepath
        var backupPathStr   = string.Format("../../Update/{0}/{1}/{2}/{3}/BundleAsset", config[0], config[1], config[2], ver);
        var backupPath      = Path.Combine(Application.dataPath, backupPathStr);
        var assetBundlePath = Path.Combine(Application.dataPath, "BundleAsset");

        DllBackupPath = backupPath;



        var svnVer     = string.Format("../../Update/{0}/{1}/{2}/{3}/svn.ver", config[0], config[1], config[2], ver);
        var svnVerPath = Path.Combine(Application.dataPath, svnVer);

        if (!File.Exists(svnVerPath))
        {
            throw new Exception("找不到上次svn版本号文件" + svnVerPath);
        }

        ModifyVersionFile(versionFullPath, 1);

        if (cSharp.Equals("1"))
        {
            GenerateAssemblyCSharpToRes(versionFullPath);
        }

        var svnVersion = File.ReadAllText(svnVerPath);

        RunLinuxShell(buildPath + "Getsvndiff.sh", svnVersion, Application.dataPath);
        var diffPath = Path.Combine(buildPath, "changelist.txt");

        if (!File.Exists(diffPath))
        {
            throw new Exception("生成svndiff失败!!");
        }

        var difflist = GetDiffList(diffPath);

        AssetBundleManagerEditor.CreateAssetBundleWithDiffList(difflist, cSharp.Equals("1"), script.Equals("1"));

        Logger.Debug("CreateAssetBundleWithDiffList finish!");


        RunLinuxShell(buildPath + "SaveSvnVersion.sh", Application.dataPath, svnVerPath);


        DirectoryCopy(assetBundlePath, backupPath, true);

        CleanAndroidPlugins();
    }