Exemplo n.º 1
0
    public static void exportConfig()
    {
        var files = AssetDatabase.GetAllAssetPaths().Where(p =>
                                                           p.StartsWith("Assets/Config") &&
                                                           p.EndsWith(".csv")
                                                           ).ToArray();

        BuildScript.CheckstreamingAssetsPath();
        string cname = CUtils.GetRightFileName(Common.CONFIG_CSV_NAME);

        BuildScript.BuildABs(files.ToArray(), null, cname, BuildAssetBundleOptions.DeterministicAssetBundle);
        Debug.Log(" Config export " + cname);
    }
Exemplo n.º 2
0
    public static void exportLanguage()
    {
        string assetPath = "Assets/Lan/";

        var files = AssetDatabase.GetAllAssetPaths().Where(p =>
                                                           p.StartsWith(assetPath) &&
                                                           p.EndsWith(".csv")
                                                           ).ToArray();

        BuildScript.CheckstreamingAssetsPath();

        foreach (string abPath in files)
        {
            string name   = CUtils.GetAssetName(abPath);
            string abName = CUtils.GetRightFileName(name + "." + Common.LANGUAGE_SUFFIX);
            BuildScript.BuildABs(new string[] { abPath }, null, abName, BuildAssetBundleOptions.CompleteAssets);
            Debug.Log(name + " " + abName + " export");
        }
    }
Exemplo n.º 3
0
    public static void exportLua()
    {
        checkLuaExportPath();
        BuildScript.CheckstreamingAssetsPath();

        string info  = "luac";
        string title = "build lua";

        EditorUtility.DisplayProgressBar(title, info, 0);

        var childrens = AssetDatabase.GetAllAssetPaths().Where(p =>
                                                               (p.StartsWith("Assets/Lua") ||
                                                                p.StartsWith("Assets/Config")) &&
                                                               (p.EndsWith(".lua"))
                                                               ).ToArray();
        string path  = "Assets/Lua/";    //lua path
        string path1 = "Assets/Config/"; //config path
        string root  = Application.dataPath.Replace("Assets", "");

        Debug.Log("luajit path = " + luacPath);
        string crypName = "", fileName = "", outfilePath = "", arg = "";

        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        //refresh directory
        DirectoryDelete(Application.dataPath + OutLuaPath);
        CheckDirectory(Application.dataPath + OutLuaPath);

        float allLen = childrens.Length;
        float i      = 0;

        List <string> exportNames = new List <string>();

        foreach (string file in childrens)
        {
            string filePath = Path.Combine(root, file);
            fileName    = CUtils.GetAssetName(filePath);
            crypName    = file.Replace(path, "").Replace(path1, "").Replace(".lua", "." + Common.LUA_LC_SUFFIX).Replace("\\", "_").Replace("/", "_");
            outfilePath = Application.dataPath + OutLuaPath + crypName;
            exportNames.Add("Assets" + OutLuaPath + crypName);
            sb.Append(fileName);
            sb.Append("=");
            sb.Append(crypName);
            sb.Append("\n");

#if Nlua || UNITY_IPHONE
            arg = "-o " + outfilePath + " " + filePath; // luac
            File.Copy(filePath, outfilePath, true);     // source code copy
#else
            arg = "-b " + filePath + " " + outfilePath; //for jit
            //Debug.Log(arg);
            //System.Diagnostics.Process.Start(luacPath, arg);//jit
            File.Copy(filePath, outfilePath, true);// source code copy
#endif
            i++;
            EditorUtility.DisplayProgressBar(title, info + "=>" + i.ToString() + "/" + allLen.ToString(), i / allLen);
        }
        Debug.Log("lua:" + path + "files=" + childrens.Length + " completed");
        System.Threading.Thread.Sleep(1000);
        AssetDatabase.Refresh();

        EditorUtility.DisplayProgressBar(title, "build lua", 0.99f);
        //u5 打包
        CheckDirectory(Path.Combine(Application.dataPath, OutLuaPath));
        BuildScript.BuildABs(exportNames.ToArray(), "Assets" + OutLuaPath, "luaout.bytes", BuildAssetBundleOptions.DeterministicAssetBundle);

        EditorUtility.DisplayProgressBar(title, "Encrypt lua", 0.99f);
        //Encrypt
        string tarName     = Application.dataPath + OutLuaPath + "luaout.bytes";
        string md5Name     = CUtils.GetRightFileName(Common.LUA_ASSETBUNDLE_FILENAME);
        string realOutPath = Path.Combine(BuildScript.GetOutPutPath(), md5Name);

        byte[] by      = File.ReadAllBytes(tarName);
        byte[] Encrypt = CryptographHelper.Encrypt(by, GetKey(), GetIV());
        File.WriteAllBytes(realOutPath, Encrypt);
        Debug.Log(realOutPath + " export");
        EditorUtility.ClearProgressBar();
    }