示例#1
0
文件: APKZip.cs 项目: clime57/Stars
    static public void reCompress(string apkFilename)
    {
        string FileNameWithoutExtension = Path.GetFileNameWithoutExtension(apkFilename);

        ZipHelper.UnZip(apkFilename, FileNameWithoutExtension, "", true);
        List <string> storeLvFiles = new List <string>();

        storeLvFiles.Add("assets/GameStory.mp4");
        storeLvFiles.Add("assets/FSN_Show1.mp4");
        storeLvFiles.Add("assets/FSN_GilgameshShow.mp4");
        APKZip.ZipFileDirectory(FileNameWithoutExtension + "/", FileNameWithoutExtension + "_Compress.apk", storeLvFiles);
        Directory.Delete(FileNameWithoutExtension, true);
        File.Delete(apkFilename);
        File.Move(FileNameWithoutExtension + "_Compress.apk", apkFilename);
    }
示例#2
0
文件: Publish.cs 项目: clime57/Stars
    static public void BuildAPK(bool tip = true, bool isRecomress = false, bool isEncrypt = false, string fileName = "")
    {
        if (tip)
        {
            if (!EditorUtility.DisplayDialog("提示", "要开始打APK包啰?", "确定", "取消"))
            {
                return;
            }
        }
        delOtherPlatformAssetBundle(BuildTarget.Android);
        string   result      = null;
        DateTime dt          = DateTime.Now.ToLocalTime();
        string   apkFilename = dt.Year.ToString("d2") + dt.Month.ToString("d2") + dt.Day.ToString("d2") +
                               dt.Hour.ToString("d2") + dt.Minute.ToString("d2");
        string apkPath = apkFilename + ".apk";

        if (fileName != "")
        {
            apkPath = fileName;
        }
        Debug.Log("apk filename = " + apkPath);
        try
        {
            result =
                BuildPipeline.BuildPlayer(
                    (from scene in EditorBuildSettings.scenes where scene.enabled select scene.path).ToArray(),
                    apkPath, BuildTarget.Android, BuildOptions.None);
        }
        catch (Exception exception)
        {
            Debug.LogError(exception);
            return;
        }
        if (!String.IsNullOrEmpty(result))
        {
            Debug.LogError(result);
            return;
        }
        if (isRecomress)
        {
            APKZip.reCompress(apkPath);
        }
        EditorUtility.DisplayDialog("提示", "恭喜!您的APK包" + System.IO.Directory.GetCurrentDirectory() + "/" + apkPath + "生成完毕!", "确定");
    }