Esempio n. 1
0
    static public void buildAndroid()
    {
        BuildTarget type = BuildTarget.Android;

        copyWWise(type);
        copyABRes(type);
        //createVersion();
        AssetDatabase.Refresh();
        PlayerSettings.Android.keystoreName = Application.dataPath + "/../SDK/user.keystore";
        PlayerSettings.Android.keyaliasPass = "******";

        PlayerSettings.Android.keyaliasName      = "star";
        PlayerSettings.Android.keystorePass      = "******";
        PlayerSettings.Android.bundleVersionCode = VersionEditorManager.Instance().getVersionNum();
        BuildPipeline.BuildPlayer(levels, BuildUtil.getPath() + "/proj.apk", BuildTarget.Android, BuildOptions.ShowBuiltPlayer);
    }
Esempio n. 2
0
    public void buildPatch()
    {
        //1. 创建当前版本目录
        string folderName = VersionEditorManager.Instance().curVersion.Replace(".", "_");

        folderName = targetPath + folderName;
        if (Directory.Exists(folderName))
        {
            return;
        }

        PatchInfo patchInfo = new PatchInfo(VersionEditorManager.Instance().curVersion);

        Directory.CreateDirectory(folderName);

        //2. 统计当前版本所有文件信息,保存至文本文件
        List <string> fileSystemEntries = new List <string>();

        fileSystemEntries.AddRange(Directory.GetFiles(sourcePath, "*", SearchOption.AllDirectories));

        FileStream   fs = new FileStream(folderName + "/files.txt", FileMode.CreateNew);
        StreamWriter sw = new StreamWriter(fs);

        for (int i = 0; i < fileSystemEntries.Count; i++)
        {
            string file = fileSystemEntries[i];
            file = file.Replace("\\", "/");

            if (file.EndsWith(".meta") || file.Contains(".DS_Store") || (file.Contains(".manifest") && !(file.Contains(BuildUtil.getPlatformManifest()))))
            {
                continue;
            }

            FileStream fileStream = new FileStream(file, FileMode.Open);

            int size = (int)fileStream.Length;

            string md5     = FileUtil.FSToMD5(fileStream);
            string value   = file.Replace(sourcePath, string.Empty).Substring(1);
            string content = value + "|" + md5 + "|" + size;
            patchInfo.addFileInfo(content);
            sw.WriteLine(content);
            fileStream.Close();
            Packager.UpdateProgress(i, fileSystemEntries.Count, "Generating file list..");
        }
        sw.Close(); fs.Close();

        //3.与历史版本对比压缩所有差异文件
        foreach (PatchInfo pInfo in patchList)
        {
            ArrayList diffFiles = pInfo.getDiffFiles(patchInfo);
            if (diffFiles.Count == 0)
            {
                continue;
            }

            FileStream      commonStream = new FileStream(pInfo.getPatchPath() + "/VersionContent.zip", FileMode.Create);
            ZipOutputStream commonZipper = new ZipOutputStream(commonStream);
            commonZipper.SetLevel(5);

            FileStream      iosStream = new FileStream(pInfo.getPatchPath() + "/iOS.zip", FileMode.Create);
            ZipOutputStream iosZipper = new ZipOutputStream(iosStream);
            iosZipper.SetLevel(5);

            ZipOutputStream androidZipper = new ZipOutputStream(new FileStream(pInfo.getPatchPath() + "/Android.zip", FileMode.Create));
            androidZipper.SetLevel(5);
            ZipOutputStream winZipper = new ZipOutputStream(new FileStream(pInfo.getPatchPath() + "/Windows.zip", FileMode.Create));
            winZipper.SetLevel(5);

            string versionNum = pInfo.ver.proCurVersion;
            for (int i = 0; i < diffFiles.Count; i++)
            {
                string          fileName   = diffFiles[i] as string;
                ZipOutputStream compressor = commonZipper;
                if (fileName.Contains("AssetBundles/iOS/") || fileName.Contains("Audio/GeneratedSoundBanks/iOS/"))
                {
                    compressor = iosZipper;
                }
                else if (fileName.Contains("AssetBundles/Windows/") || fileName.Contains("Audio/GeneratedSoundBanks/Windows/"))
                {
                    compressor = winZipper;
                }
                else if (fileName.Contains("AssetBundles/Android/") || fileName.Contains("Audio/GeneratedSoundBanks/Android/"))
                {
                    compressor = androidZipper;
                }
                compressor.PutNextEntry(new ZipEntry(fileName));
                string fullPath = sourcePath + "/" + fileName;
                Packager.UpdateProgress(i, diffFiles.Count, " Compress version: " + versionNum + " on file: " + fileName);
                byte[] data = new byte[2048];
                using (FileStream input = File.OpenRead(fullPath))
                {
                    int bytesRead;
                    while ((bytesRead = input.Read(data, 0, data.Length)) > 0)
                    {
                        compressor.Write(data, 0, bytesRead);
                    }
                }
            }
            commonZipper.Finish();
            iosZipper.Finish();
            androidZipper.Finish();
            winZipper.Finish();
        }

        //4. 记录当前版本号
        VersionEditorManager.Instance().saveVersion(targetPath + "version.txt");


        fs = new FileStream(folderName + "/mark.txt", FileMode.CreateNew);
        fs.Close();
        EditorUtility.ClearProgressBar();
    }
Esempio n. 3
0
 void OnEnable()
 {
     myVersion = VersionEditorManager.Instance().curVersion;
     Packager.Init();
 }
Esempio n. 4
0
    void OnGUI()
    {
        GUILayout.Label(" 指定当前版本号, 与服务器保持一致", EditorStyles.boldLabel);
        myVersion = GUILayout.TextField(myVersion);
        GUILayout.Space(20);

        // =========================== 3. 标记AB资源   ===========================
        if (GUILayout.Button("刷新版本", GUILayout.Height(30)))
        {
            string[] szAssetBundleNames = AssetDatabase.GetAllAssetBundleNames();
            for (int i = 0; i < szAssetBundleNames.Length; i++)
            {
                AssetDatabase.RemoveAssetBundleName(szAssetBundleNames[i], true);
            }

            VersionEditorManager.Instance().curVersion = myVersion;
            PlayerSettings.Android.bundleVersionCode = VersionEditorManager.Instance().getVersionNum();
            PlayerSettings.bundleVersion             = myVersion;
        }

        GUILayout.Space(30);

        //=========================== 1.选择平台 ================================
        GUILayout.Label(" 选择发布平台  ", EditorStyles.boldLabel);
        GUILayout.Space(20);

        TargetPlatform select = (TargetPlatform)EditorGUILayout.EnumPopup(Packager.curTarget);

        if (select != Packager.curTarget)
        {
            // 重新判断当前版本设定
            Packager.curTarget = select;
        }

        GUILayout.Space(20);

        // =========================== 3. 标记AB资源   ===========================
        if (GUILayout.Button("标记AB", GUILayout.Height(30)))
        {
            Packager.BuildAssetMarks();
            Packager.WritePreloadFile();
            BuildUtil.createVersion();
        }

        GUILayout.Space(20);

        if (GUILayout.Button("生成AB", GUILayout.Height(30)))
        {
            Packager.ClearABFolder();
            Packager.GenerateAB();
        }

        // =========================== 4. 是否读取AB包  ===========================
        bool cur = GUILayout.Toggle(Packager.bLoadAB, "读取AB包");

        if (Packager.bLoadAB != cur)
        {
            Packager.bLoadAB = cur;
            AssetBundleManager.SimulateAssetBundleInEditor = !Packager.bLoadAB;
        }

        GUILayout.Space(20);
        GUIContent content = new GUIContent(" 请确认完成了 AB包 的制做过程 !!!");
        GUIStyle   style   = new GUIStyle();

        style.fontStyle = FontStyle.Normal;
        style.fontSize  = 13;

        GUILayout.Label(content);
        GUILayout.Space(20);
        GUILayout.Label(" 选择发布版本类型:");
        GUILayout.Space(20);
        BuildTargetGroup curGroup  = transPlatform(Packager.curTarget);
        string           curSymbol = null;

        if (curSelect == -1)
        {
            curSymbol = PlayerSettings.GetScriptingDefineSymbolsForGroup(curGroup);
            if (curSymbol.IndexOf("RELEASE_VER", 0, curSymbol.Length) == -1)
            {
                curSelect = 0;
            }
            else
            {
                if (curSymbol.IndexOf("STORE_VERSION", 0, curSymbol.Length) == -1)
                {
                    curSelect = 1;
                }
                else
                {
                    curSelect = 2;
                }
            }
        }

        int newSelect = GUILayout.SelectionGrid(curSelect, verList, 6);

        //处理不同版本的一些 PlayerSetting 设置
        if (newSelect != curSelect)
        {
            curSelect = newSelect;
            curSymbol = PlayerSettings.GetScriptingDefineSymbolsForGroup(curGroup);
            switch (curSelect)
            {
            case 0:
            {
                curSymbol = curSymbol.Replace("RELEASE_VER", "DEVELOP_VERSION");
                curSymbol = curSymbol.Replace("STORE_VERSION", "DEVELOP_VERSION");
                if (curSymbol.IndexOf("DEVELOP_VERSION", 0, curSymbol.Length) == -1)
                {
                    if (!string.IsNullOrEmpty(curSymbol))
                    {
                        curSymbol += ";";
                    }
                    curSymbol += "DEVELOP_VERSION";
                }
            }
            break;

            case 1:
            {
                curSymbol = curSymbol.Replace("DEVELOP_VERSION", "RELEASE_VER");
                curSymbol = curSymbol.Replace("STORE_VERSION", "RELEASE_VER");
                if (curSymbol.IndexOf("RELEASE_VER", 0, curSymbol.Length) == -1)
                {
                    if (!string.IsNullOrEmpty(curSymbol))
                    {
                        curSymbol += ";";
                    }
                    curSymbol += "RELEASE_VER";
                }
            }
            break;

            case 2:
            {
                curSymbol = curSymbol.Replace("DEVELOP_VERSION", "STORE_VERSION");
                curSymbol = curSymbol.Replace("RELEASE_VER", "STORE_VERSION");
                if (curSymbol.IndexOf("STORE_VERSION", 0, curSymbol.Length) == -1)
                {
                    if (!string.IsNullOrEmpty(curSymbol))
                    {
                        curSymbol += ";";
                    }
                    curSymbol += "STORE_VERSION";
                }
            }
            break;
            }

            PlayerSettings.SetScriptingDefineSymbolsForGroup(curGroup, curSymbol);
            Debug.Log(curSymbol);
        }
        GUILayout.Space(20);
        // =========================== 4. 拷贝资源    ===========================
        if (GUILayout.Button("拷贝资源 ", GUILayout.Height(30)))
        {
            switch (Packager.curTarget)
            {
            case TargetPlatform.IOS:
                BuildUtil.copyPlatformRes(BuildTarget.iOS);
                break;

            case TargetPlatform.Windows:
                BuildUtil.copyPlatformRes(BuildTarget.StandaloneWindows);
                break;

            case TargetPlatform.Android:
                BuildUtil.copyPlatformRes(BuildTarget.Android);
                break;

            case TargetPlatform.WebGL:
                BuildUtil.copyPlatformRes(BuildTarget.WebGL);
                break;
            }
            AssetDatabase.Refresh();
        }
        GUILayout.Space(20);
        // =========================== 5. 生成安装包    ===========================
        if (GUILayout.Button("生成安装包 ", GUILayout.Height(30)))
        {
            if (myVersion.Length == 0 || myVersion.Equals("0.0.0"))
            {
                EditorUtility.DisplayDialog(" Error !!", " 请修改版本为有效数字", "确定");
            }
            else
            {
                switch (Packager.curTarget)
                {
                case TargetPlatform.IOS:
                    BuildUtil.buildIOS();
                    break;

                case TargetPlatform.Windows:
                    BuildUtil.buildWindows();
                    break;

                case TargetPlatform.Android:
                    BuildUtil.buildAndroid();
                    break;

                case TargetPlatform.WebGL:
                    BuildUtil.buildWebGL();
                    break;
                }
            }
        }
        ;
        GUILayout.Space(20);

        if (Packager.curTarget == TargetPlatform.IOS)
        {
            if (GUILayout.Button("生成IPA", GUILayout.Height(30)))
            {
                IPABuilder.buildIPA();
            }
            GUILayout.Space(20);
        }

        if (GUILayout.Button("生成版本更新包 ", GUILayout.Height(30)))
        {
            BuildUtil.PatchAll();
        }
    }