Ejemplo n.º 1
0
    static void ForBuildNpc()
    {
        int dirs=Selection.objects.Length;
        string unity3dFileName;
        for(int i=0;i<dirs;i++){
            string path = AssetDatabase.GetAssetPath(Selection.objects[i]);
            if(path.Length!=0){
                int pos=path.LastIndexOf("/");
                if (pos<0) pos = 0;
                unity3dFileName = path.Substring(pos);
                ExportAssetBundles exp=new ExportAssetBundles();
                string[] fileEntries = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);//仅本级目
                Object[] objects = new Object[fileEntries.Length];
                for (int k = 0; k < fileEntries.Length; k++){
                    string filepath=fileEntries[k];
                    string localpath=filepath.Replace("\\","/");
                    objects[k]=AssetDatabase.LoadMainAssetAtPath(localpath);
                }
                string str=path.Substring(0,path.IndexOf("/"))+"/npcpackage" + unity3dFileName + ".unity3d";
                BuildPipeline.BuildAssetBundle(objects[0],objects,str,BuildAssetBundleOptions.CollectDependencies
                                               | BuildAssetBundleOptions.CompleteAssets,BuildTarget.Android);

            }
        }
    }
Ejemplo n.º 2
0
    public static void exportLua()
    {
        checkLuaExportPath();

        string path  = Application.dataPath + "/Lua/";    //lua path
        string path1 = Application.dataPath + "/Config/"; //config path

        List <string> files = getAllChildFiles(path);     // Directory.GetFiles(Application.dataPath + path);

        getAllChildFiles(path1, "lua", files);

        IList <string> childrens = new List <string>();

        foreach (string file in files)
        {
            if (file.EndsWith("lua"))
            {
                childrens.Add(file);
            }
        }
        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);

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

        foreach (string filePath in childrens)
        {
            fileName    = CUtils.GetURLFileName(filePath);
            crypName    = filePath.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
        }
        Debug.Log("lua:" + path + "files=" + files.Count + " completed");
        System.Threading.Thread.Sleep(1000);
        AssetDatabase.Refresh();

        //u5 打包
        string outPath = ExportAssetBundles.GetOutPath();
        CheckDirectory(Application.dataPath.Replace("Assets", "") + outPath);
        ExportAssetBundles.BuildABs(exportNames.ToArray(), "Assets" + OutLuaPath, "luaout.bytes", BuildAssetBundleOptions.CompleteAssets);

        //Encrypt
        string tarName     = Application.dataPath + OutLuaPath + "luaout.bytes";
        string realOutPath = ExportAssetBundles.GetOutPath() + "/font.u3d";
        byte[] by          = File.ReadAllBytes(tarName);
        byte[] Encrypt     = CryptographHelper.Encrypt(by, GetKey(), GetIV());
        File.WriteAllBytes(realOutPath, Encrypt);
        Debug.Log(realOutPath + " export");
    }
Ejemplo n.º 3
0
    public static void exportPublish()
    {
        ExportResources.DirectoryDelete(Path.Combine(Application.streamingAssetsPath, ExportAssetBundles.GetTarget().ToString()));

        BuildScript.BuildAssetBundles(); //导出资源

        exportLua();

        exportConfig();

        exportLanguage();

        autoVerAdd();
    }