Ejemplo n.º 1
0
        public static void GenResBuildByDir(string dir, string pattern)
        {
            string relative2 = sResDir;

            if (!string.IsNullOrEmpty(dir) && Directory.Exists(dir))
            {
                //查看该文件夹下是否有文件,有文件将该文件夹作为一个bundle
                string[] files = Directory.GetFiles(dir, pattern, SearchOption.TopDirectoryOnly);
                int      count = 0;
                foreach (var f in files)
                {
                    if (BuilderConfig.IsResFile(f))
                    {
                        count += AsbNameSetting.GetHasAsbName(f) ? 0 : 1;
                        break;
                    }
                }
                if (count > 0)
                {
                    files = Directory.GetFiles(dir, pattern, SearchOption.AllDirectories);
                    string asbName = Tools.GetAsbName(Tools.RelativeTo(dir, relative2));
                    // List<string> list = new List<string>();
                    for (int i = 0; i < files.Length; i++)
                    {
                        string f = files[i];
                        if (BuilderConfig.IsResFile(f))
                        {
                            string resPath = Tools.RelativeTo(f, Application.dataPath, true);
                            AsbNameSetting.SetBundleName(resPath, asbName, true);
                        }
                    }
                }
                else
                {
                    //如果文件夹下没有文件,遍历其子文件夹
                    string[] dirs = Directory.GetDirectories(dir);
                    if (dirs.Length > 0)
                    {
                        foreach (var d in dirs)
                        {
                            GenResBuildByDir(d, pattern);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void GenLuaBuildByDir(string dir, string pattern)
        {
            if (!string.IsNullOrEmpty(dir) && Directory.Exists(dir))
            {
                string   relative2 = sTempLuaDir;
                string[] files     = Directory.GetFiles(dir, pattern, SearchOption.TopDirectoryOnly);
                string   asbName   = "lua/" + Tools.GetAsbName(Tools.RelativeTo(dir, relative2, true));

                for (int i = 0; i < files.Length; i++)
                {
                    string f = files[i];
                    if (BuilderConfig.IsResFile(f))
                    {
                        AsbNameSetting.SetBundleName(Tools.RelativeTo(files[i], Application.dataPath, true), asbName, true);
                    }
                }
            }
        }