CheckstreamingAssetsPath() public static method

检查输出目标
public static CheckstreamingAssetsPath ( ) : void
return void
Example #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);
        }
Example #2
0
        public static void exportConfig()
        {
            var files = AssetDatabase.GetAllAssetPaths().Where(p =>
                                                               p.StartsWith("Assets/Config") || !p.StartsWith("Assets/Config/Lan") &&
                                                               p.EndsWith(".csv")
                                                               ).ToArray();

            BuildScript.CheckstreamingAssetsPath();

            if (files.Length > 0)
            {
                string cname = CUtils.GetRightFileName(Common.CONFIG_CSV_NAME);
                BuildScript.BuildABs(files.ToArray(), null, cname, SplitPackage.DefaultBuildAssetBundleOptions);
                Debug.Log(" Config export " + cname);
            }
        }
Example #3
0
        public static void exportLanguage()
        {
            var files = AssetDatabase.GetAllAssetPaths().Where(p =>
                                                               p.StartsWith("Assets/Config/Lan") &&
                                                               p.EndsWith(".csv")
                                                               ).ToArray();

            BuildScript.CheckstreamingAssetsPath();

            foreach (string abPath in files)
            {
                string name   = CUtils.GetAssetName(abPath);
                string abName = CUtils.GetRightFileName(name + Common.CHECK_ASSETBUNDLE_SUFFIX);
                BuildScript.BuildABs(new string[] { abPath }, null, abName, BuildAssetBundleOptions.None);
                Debug.Log(name + " " + abName + " export");
            }
        }
Example #4
0
        public static void exportLanguage()
        {
            var files = AssetDatabase.GetAllAssetPaths().Where(p =>
                                                               p.StartsWith("Assets/Config/Lan") &&
                                                               p.EndsWith(".csv")
                                                               ).ToArray();

            BuildScript.CheckstreamingAssetsPath();
            // BuildScript.ch
            foreach (string abPath in files)
            {
                string            name   = CUtils.GetAssetName(abPath);
                string            abName = CUtils.GetRightFileName(name + Common.CHECK_ASSETBUNDLE_SUFFIX);
                Hugula.BytesAsset bytes  = (Hugula.BytesAsset)ScriptableObject.CreateInstance(typeof(Hugula.BytesAsset));
                bytes.bytes = File.ReadAllBytes(abPath);
                string bytesPath = string.Format("Assets/Tmp/{0}.asset", name);
                AssetDatabase.CreateAsset(bytes, bytesPath);
                BuildScript.BuildABs(new string[] { bytesPath }, null, abName, SplitPackage.DefaultBuildAssetBundleOptions);
                Debug.Log(name + " " + abName + " export");
            }
        }
Example #5
0
        public static void doExportLua(string[] childrens, bool android_ab_build = false)
        {
            BuildScript.CheckstreamingAssetsPath();

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

            EditorUtility.DisplayProgressBar(title, info, 0);

            var checkChildrens = 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  = CurrentRootFolder; //Application.dataPath.Replace("Assets", "");

            string crypName = "", fileName = "", outfilePath = "", arg = "";

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            //refresh directory
            if (checkChildrens.Length == childrens.Length)
            {
                DirectoryDelete(OutLuaPath);
            }
            CheckDirectory(OutLuaPath);

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

            System.Diagnostics.Process luaProccess = new System.Diagnostics.Process();
            luaProccess.StartInfo.CreateNoWindow = true;
            luaProccess.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
            luaProccess.StartInfo.FileName       = luacPath;

            System.Diagnostics.Process luajit32Proccess = new System.Diagnostics.Process();
            luajit32Proccess.StartInfo.CreateNoWindow   = true;
            luajit32Proccess.StartInfo.WindowStyle      = System.Diagnostics.ProcessWindowStyle.Hidden;
            luajit32Proccess.StartInfo.FileName         = luajit32Path;
            luajit32Proccess.StartInfo.WorkingDirectory = luaWorkingPath;

            System.Diagnostics.Process luajit64Proccess = new System.Diagnostics.Process();
            luajit64Proccess.StartInfo.CreateNoWindow   = true;
            luajit64Proccess.StartInfo.WindowStyle      = System.Diagnostics.ProcessWindowStyle.Hidden;
            luajit64Proccess.StartInfo.FileName         = luajit64Path;
            luajit64Proccess.StartInfo.WorkingDirectory = luaWorkingPath;

            Debug.Log("luajit32Path:" + luajit32Path);
            Debug.Log("luajit64Path:" + luajit64Path);
            Debug.Log("luacPath:" + luacPath);
#if UNITY_ANDROID
            string streamingAssetsPath = Path.Combine(CurrentRootFolder, LuaTmpPath);
            DirectoryDelete(streamingAssetsPath);
            CheckDirectory(streamingAssetsPath);
#else
            string streamingAssetsPath = CUtils.realStreamingAssetsPath;
#endif
            Debug.Log(streamingAssetsPath);
            luaProccess.StartInfo.WorkingDirectory = luaWorkingPath;
            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("/", "+");

                if (!string.IsNullOrEmpty(luajit32Path))// luajit32
                {
                    string override_name = CUtils.GetRightFileName(crypName);
                    string override_lua  = Path.Combine(streamingAssetsPath, override_name);
                    arg = "-b " + filePath + " " + override_lua; //for jit
                    luajit32Proccess.StartInfo.Arguments = arg;
                    luajit32Proccess.Start();
                    luajit32Proccess.WaitForExit();
#if UNITY_ANDROID
                    Debug.Log(luajit32Proccess.StartInfo.FileName + " " + arg);
                    exportNames.Add(Path.Combine(LuaTmpPath, override_name));
#endif
                    sb.AppendLine("[\"" + crypName + "\"] = { name = \"" + override_name + "\", path = \"" + file + "\", out path = \"" + override_lua + "\"},");
                }
                if (!string.IsNullOrEmpty(luajit64Path)) //luajit64
                {
                    string crypName_64   = CUtils.InsertAssetBundleName(crypName, "_64");
                    string override_name = CUtils.GetRightFileName(crypName_64);
                    string override_lua  = Path.Combine(streamingAssetsPath, override_name);
                    arg = "-b " + filePath + " " + override_lua; //for jit
                    luajit64Proccess.StartInfo.Arguments = arg;
                    luajit64Proccess.Start();
                    luajit64Proccess.WaitForExit();
                    sb.AppendLine("[\"" + crypName_64 + "\"] = { name = \"" + override_name + "\", path = \"" + file + "\", out path = \"" + override_lua + "\"},");
                }
                if (!string.IsNullOrEmpty(luacPath))                          //for editor
                {
                    string override_name = CUtils.GetRightFileName(crypName); //CUtils.GetRightFileName(CUtils.InsertAssetBundleName(crypName,"_64"));
                    string override_lua  = Path.Combine(OutLuaPath, override_name);
#if UNITY_EDITOR_OSX && !UNITY_STANDALONE_WIN
                    arg = "-o " + override_lua + " " + filePath; //for lua
#else
                    arg = "-b " + filePath + " " + override_lua; //for jit
#endif
                    luaProccess.StartInfo.Arguments = arg;
                    luaProccess.Start();
                    luaProccess.WaitForExit();
                    sb.AppendLine("[\"" + crypName + "(editor)\"] = { name = \"" + override_name + "\", path = \"" + file + "\", out path = \"" + override_lua + "\"},");
                }
                i++;
                EditorUtility.DisplayProgressBar(title, info + "=>" + i.ToString() + "/" + allLen.ToString(), i / allLen);
            }

            Debug.Log("lua:" + path + "files=" + childrens.Length + " completed");
            System.Threading.Thread.Sleep(100);
            //AssetDatabase.Refresh();

            //out md5 mapping file
            string tmpPath = BuildScript.GetAssetTmpPath();
            ExportResources.CheckDirectory(tmpPath);
            string outPath = Path.Combine(tmpPath, "lua_md5mapping.txt");
            Debug.Log("write to path=" + outPath);
            using (StreamWriter sr = new StreamWriter(outPath, false))
            {
                sr.Write(sb.ToString());
            }

            //
#if UNITY_ANDROID
            if (android_ab_build)
            {
                title  = "lua bytes to asset";
                allLen = exportNames.Count;
                i      = 0;
                string luaStreamingAssetsPath = "Assets" + CUtils.realStreamingAssetsPath.Replace(Application.dataPath, "");
                Debug.Log(luaStreamingAssetsPath);
                // AssetImporter import = null;
                List <AssetBundleBuild> abbs = new List <AssetBundleBuild>();
                foreach (var luapath in exportNames)
                {
                    try
                    {
                        byte[] luabytes   = File.ReadAllBytes(luapath);
                        string assetName  = Path.GetFileName(luapath);//CUtils.GetAssetBundleName(luapath);
                        var    bytesAsset = ScriptableObject.CreateInstance <BytesAsset>();
                        bytesAsset.bytes = luabytes;
                        string assetPath = luapath.Replace("." + Common.LUA_LC_SUFFIX, ".asset");
                        AssetDatabase.CreateAsset(bytesAsset, assetPath);
                        AssetBundleBuild abb = new AssetBundleBuild();
                        abb.assetBundleName = assetName;
                        abb.assetNames      = new string[] { assetPath };
                        abbs.Add(abb);
                        i++;
                        EditorUtility.DisplayProgressBar(title, info + "=>" + i.ToString() + "/" + allLen.ToString(), i / allLen);
                    }
                    catch (System.Exception e)
                    {
                        Debug.LogError(e.ToString());
                    }
                }

                title  = "lua asset to assetbundle";
                allLen = abbs.Count;
                i      = 0;

                // foreach (var abb in abbs)
                // {
                //     BuildScript.BuildABs(abb.assetNames, null, abb.assetBundleName, BuildAssetBundleOptions.None);
                //     i++;
                //     EditorUtility.DisplayProgressBar(title, info + "=>" + i.ToString() + "/" + allLen.ToString(), i / allLen);
                // }

                title = "build lua assetbundle ";
                EditorUtility.DisplayProgressBar(title, info + "=>", 1);

                BuildScript.BuildABs(abbs.ToArray(), null, BuildAssetBundleOptions.None);
            }
#endif

            EditorUtility.ClearProgressBar();
        }
Example #6
0
        public static void doExportLua(string[] childrens)
        {
            BuildScript.CheckstreamingAssetsPath();

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

            EditorUtility.DisplayProgressBar(title, info, 0);

            var checkChildrens = 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  = CurrentRootFolder; //Application.dataPath.Replace("Assets", "");

            string crypName = "", crypEditorName = "", fileName = "", outfilePath = "", arg = "";

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            //refresh directory
            if (checkChildrens.Length == childrens.Length)
            {
                DirectoryDelete(OutLuaPath);
            }
            CheckDirectory(OutLuaPath);

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

            System.Diagnostics.Process luaProccess = new System.Diagnostics.Process();
            luaProccess.StartInfo.CreateNoWindow = true;
            luaProccess.StartInfo.WindowStyle    = System.Diagnostics.ProcessWindowStyle.Hidden;
            luaProccess.StartInfo.FileName       = luacPath;

            System.Diagnostics.Process luajit32Proccess = new System.Diagnostics.Process();
            luajit32Proccess.StartInfo.CreateNoWindow   = true;
            luajit32Proccess.StartInfo.WindowStyle      = System.Diagnostics.ProcessWindowStyle.Hidden;
            luajit32Proccess.StartInfo.FileName         = luajit32Path;
            luajit32Proccess.StartInfo.WorkingDirectory = luaWorkingPath;

            System.Diagnostics.Process luajit64Proccess = new System.Diagnostics.Process();
            luajit64Proccess.StartInfo.CreateNoWindow   = true;
            luajit64Proccess.StartInfo.WindowStyle      = System.Diagnostics.ProcessWindowStyle.Hidden;
            luajit64Proccess.StartInfo.FileName         = luajit64Path;
            luajit64Proccess.StartInfo.WorkingDirectory = luaWorkingPath;

            Debug.Log("luajit32Path:" + luajit32Path);
            Debug.Log("luajit64Path:" + luajit64Path);
            Debug.Log("luacPath:" + luacPath);

            string streamingAssetsPath = OutLuaBytesPath;  //Path.Combine(CurrentRootFolder, LuaTmpPath);

            DirectoryDelete(streamingAssetsPath);
            CheckDirectory(streamingAssetsPath);

            Debug.Log(streamingAssetsPath);
            luaProccess.StartInfo.WorkingDirectory = luaWorkingPath;

            foreach (string file in childrens)
            {
                string filePath = Path.Combine(root, file);
                fileName       = CUtils.GetAssetName(filePath);
                crypName       = file.Replace(path, "").Replace(path1, "").Replace(".lua", ".bytes").Replace("\\", "+").Replace("/", "+");
                crypEditorName = file.Replace(path, "").Replace(path1, "").Replace(".lua", "." + Common.LUA_LC_SUFFIX).Replace("\\", "+").Replace("/", "+");
                if (!string.IsNullOrEmpty(luajit32Path))// luajit32
                {
                    string override_name = CUtils.GetRightFileName(crypName);
                    string override_lua  = Path.Combine(streamingAssetsPath, override_name);
                    arg = "-b " + filePath + " " + override_lua; //for jit
                    // Debug.Log(arg);
                    luajit32Proccess.StartInfo.Arguments = arg;
                    luajit32Proccess.Start();
                    luajit32Proccess.WaitForExit();
                    sb.AppendLine("[\"" + crypName + "\"] = { name = \"" + override_name + "\", path = \"" + file + "\", out path = \"" + override_lua + "\"},");
                }
                if (!string.IsNullOrEmpty(luajit64Path)) //luajit64
                {
                    string crypName_64   = CUtils.InsertAssetBundleName(crypName, "_64");
                    string override_name = CUtils.GetRightFileName(crypName_64);
                    string override_lua  = Path.Combine(streamingAssetsPath, override_name);
                    arg = "-b " + filePath + " " + override_lua; //for jit
                    //  Debug.Log(arg);
                    luajit64Proccess.StartInfo.Arguments = arg;
                    luajit64Proccess.Start();
                    luajit64Proccess.WaitForExit();
                    sb.AppendLine("[\"" + crypName_64 + "\"] = { name = \"" + override_name + "\", path = \"" + file + "\", out path = \"" + override_lua + "\"},");
                }
                if (!string.IsNullOrEmpty(luacPath))                                //for editor
                {
                    string override_name = CUtils.GetRightFileName(crypEditorName); //CUtils.GetRightFileName(CUtils.InsertAssetBundleName(crypName,"_64"));
                    string override_lua  = Path.Combine(OutLuaPath, override_name);
#if UNITY_EDITOR_OSX && !UNITY_STANDALONE_WIN
                    arg = "-o " + override_lua + " " + filePath; //for lua
#else
                    arg = "-b " + filePath + " " + override_lua; //for jit
#endif
                    // Debug.Log(arg);
                    luaProccess.StartInfo.Arguments = arg;
                    luaProccess.Start();
                    luaProccess.WaitForExit();
                    sb.AppendLine("[\"" + crypEditorName + "(editor)\"] = { name = \"" + override_name + "\", path = \"" + file + "\", out path = \"" + override_lua + "\"},");
                }
                i++;
                EditorUtility.DisplayProgressBar(title, info + "=>" + i.ToString() + "/" + allLen.ToString(), i / allLen);
            }

            Debug.Log("lua:" + path + "files=" + childrens.Length + " completed");
            System.Threading.Thread.Sleep(100);

            //out md5 mapping file
            string tmpPath = BuildScript.GetAssetTmpPath();
            ExportResources.CheckDirectory(tmpPath);
            string outPath = Path.Combine(tmpPath, "lua_md5mapping.txt");
            Debug.Log("write to path=" + outPath);
            using (StreamWriter sr = new StreamWriter(outPath, false))
            {
                sr.Write(sb.ToString());
            }

            EditorUtility.ClearProgressBar();
        }