Beispiel #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    public XPack GetPack(string name)
    {
        XPack pack = null;

        packs.TryGetValue(name, out pack);
        return(pack);
    }
Beispiel #2
0
    static void pack_all(BuildTarget buildTarget)
    {
        XPack pack = new XPack();

        pack.setInfo(buildTarget);
        try
        {
            System.IO.Directory.Delete(pack.targetDir, true);
        }
        catch (System.Exception e)
        {
            XDebug.LogError(e.Message);
        }

        XDebug.Log("开始打包");

        foreach (var item in instance._packItems)
        {
            if (item.type == XPackItem.XPackType.File)
            {
                string path = item.path;
                pack.pack(path);
            }
            else if (item.type == XPackItem.XPackType.DirFiles)
            {
                pack.packdirfiles(item.path, item.searchPattern, item.searchOption);
            }
            else if (item.type == XPackItem.XPackType.Dir)
            {
                pack.packdir(item.path, item.searchPattern, item.searchOption);
            }
        }

        pack.packluadir("lua/", luaJit);

        AssetBundleManifest manifest = pack.packAll();
        XPackInfo           info     = new XPackInfo();

        info.parseManifest(manifest, pack.targetDir);
        info._version      = version;
        info._firstVersion = version;
        info.saveFile(pack.targetDir + "Assets/version.json");

        XVer ver = new XVer {
            ver = version, ab = pack.getWebDir(webPublishUrl), remoteLogUrl = remoteLogURL, isRemoteLog = isRemoteLog
        };

        ver.saveFile(pack.targetDir + "Assets/ver.json");



        XDebug.Log("打包结束");
    }
Beispiel #3
0
    /// <summary>
    /// Add the specified pack.
    /// </summary>
    /// <param name="pack">Pack.</param>
    public void Add(XPack pack)
    {
#if UNITY_EDITOR
        Debug.Log(string.Format("<color=red> XSheet add [XPath] {0}.{1}.{2} </color>", pack.name, pack.size, pack.checksum));
#endif

        packs.Add(pack.name, pack);

        XLocationType local = pack.Nobundle() ? XLocationType.Resource : XLocationType.Bundle;
        foreach (string file in pack.files)
        {
            AddFastIndex(file, new XAssetInfo()
            {
                locationType = local, bundleName = pack.name, fullName = file
            });
        }
    }
Beispiel #4
0
    static string getTargetName(XPack pack, string versionDir)
    {
        if (!Directory.Exists(versionDir))
        {
            Directory.CreateDirectory(versionDir);
        }
        string builddir;

        if (pack.target == BuildTarget.Android)
        {
            builddir = versionDir + "client/" + exe + ".apk";
            if (File.Exists(builddir))
            {
                File.Delete(builddir);
            }
        }
        else if (pack.target == BuildTarget.iOS)
        {
            // 不允许有/斜杠,!!,否则拷贝不过去,汗~
            builddir = versionDir + "client/" + exe + "_ios";

            if (Directory.Exists(builddir))
            {
                Directory.Delete(builddir, true);
            }
        }
        else if (pack.target == BuildTarget.StandaloneWindows)
        {
            builddir = versionDir + "client/" + exe + ".exe";
            if (File.Exists(builddir))
            {
                File.Delete(builddir);
            }
        }
        else
        {
            builddir = versionDir + "client/" + exe + ".exe";
            if (File.Exists(builddir))
            {
                File.Delete(builddir);
            }
        }

        return(builddir);
    }
Beispiel #5
0
    static void menuPackLua()
    {
        XDebug.Log("打包lua结束");
        XPack pack = new XPack();

        pack.setInfo();
        XPackInfo info = new XPackInfo();

        if (!info.loadFile(pack.targetDir + "Assets/version.json"))
        {
            XDebug.LogError("打包lua失败,应当先打包");
            return;
        }
        XDebug.Log("打包lua");
        pack.packluadir("lua/", luaJit);
        info.saveFile(pack.targetDir + "Assets/version.json");
        XDebug.Log("打包lua结束");
    }
Beispiel #6
0
    // 发布平台
    static void build(XPack pack, string versionDir)
    {
        List <string> levels = new List <string>();

        for (int i = 0; i < EditorBuildSettings.scenes.Length; ++i)
        {
            levels.Add(EditorBuildSettings.scenes[i].path);
        }

        string builddir = getTargetName(pack, versionDir);

        BuildPipeline.BuildPlayer(levels.ToArray(), builddir, pack.target, options);

        string output = Path.GetDirectoryName(Path.GetFullPath(builddir));

        XDebug.Log(output);
        // 打开目录
        openOutputDir(output);
    }
Beispiel #7
0
    static void move_all(BuildTarget buildTarget)
    {
        delStreamingAssets();
        XPack pack = new XPack();

        pack.setInfo(buildTarget);
        XUtil.copyDirectory(pack.targetDir, "Assets/StreamingAssets", true);
        AssetDatabase.Refresh();

        // publish目录
        string versionDir = pack.getVersionDir(publishDir, "v" + version);

        // 清除所有东西
        XUtil.clearDirectory(versionDir);

        XUtil.copyDirectory(pack.targetDir, versionDir, true);


        build(pack, versionDir);

        // 拷贝单个文件
        XDebug.Log(versionDir + "assets/ver.json" + "=>" + pack.getPublishDir(publishDir) + "ver.json");
        XUtil.copyFile(versionDir + "assets/ver.json", pack.getPublishDir(publishDir) + "ver.json");
    }
Beispiel #8
0
    public Queue <XEntryDiff> GenerateSheetDiff(XSheetInfo newSheet)
    {
        Queue <XEntryDiff> diffFat = new Queue <XEntryDiff>();

        // pack diff
        for (int i = 0; i < newSheet.packs.Count; i++)
        {
            bool  diff = true;
            XPack pack = newSheet.packs[i];
            XPack localPack;
            if (packs.TryGetValue(pack.name, out localPack))
            {
                if (localPack.checksum == pack.checksum)
                {
                    diff = false;
                }
            }

            if (diff)
            {
                diffFat.Enqueue(new XEntryDiff()
                {
                    entryType = XEntryType.File, local = localPack, remote = pack
                });
            }
        }

        // file diff
        for (int i = 0; i < newSheet.files.Count; i++)
        {
            bool  diff = true;
            XFile file = newSheet.files[i];
            XFile localFile;
            if (files.TryGetValue(file.name, out localFile))
            {
                if (localFile.checksum == file.checksum)
                {
                    diff = false;
                }
            }

            if (diff)
            {
                diffFat.Enqueue(new XEntryDiff()
                {
                    entryType = XEntryType.Pack, local = localFile, remote = file
                });
            }
        }

        // scene diff
        for (int i = 0; i < newSheet.scenes.Count; i++)
        {
            bool   diff  = true;
            XScene scene = newSheet.scenes[i];
            XScene localScene;
            if (scenes.TryGetValue(scene.name, out localScene))
            {
                if (localScene.bundleName == scene.bundleName)
                {
                    diff = false;
                }
            }

            if (diff)
            {
                diffFat.Enqueue(new XEntryDiff()
                {
                    entryType = XEntryType.Scene, local = localScene, remote = scene
                });
            }
        }

        return(diffFat);
    }
Beispiel #9
0
    public static void clearBundleName()
    {
        XPack pack = new XPack();

        pack.clearBundleName();
    }
Beispiel #10
0
 static void menuMoveCur()
 {
     move_all(XPack.getCurTarget());
 }
Beispiel #11
0
 static void menuPackCur()
 {
     pack_all(XPack.getCurTarget());
 }