コード例 #1
0
    static void CopyBetweenProjectAndAB(string versionName, ExcelDirType dirType, bool isABToProject)
    {
        string excelTopDir = ExcelConfig.GetTopDir(dirType);

        string abDir = GetCurrentVersionPath(versionName);

        if (!Directory.Exists(abDir))
        {
            Debug.LogError("Error: directory doesn't exist:" + abDir);
            return;
        }

        List <FileInfo> abInfos = BuildAssetBundleHelper.GetUsefulFileInfosFromDir(abDir);

        string          projectPath = Application.dataPath;
        List <FileInfo> allInfos    = BuildAssetBundleHelper.GetUsefulFileInfosFromDir(projectPath);

        foreach (FileInfo abInfo in abInfos)
        {
            bool isExcel = abInfo.Name.EndsWith(".xls");

            FileInfo projectInfo = ListUtility.FindFirstOrDefault(allInfos, (FileInfo i) => {
                //Debug.Log("name:" + i.Name);
                bool result = abInfo.Name == i.Name;
                if (result && isExcel)
                {
                    result = IsContainDirectory(i.FullName, excelTopDir);
                }
                return(result);
            });

            if (projectInfo == null)
            {
                string errStr = "Can't find corresponding project file:" + abInfo.Name;
                Debug.LogError(errStr);
            }
            else
            {
                if (isABToProject)
                {
                    Debug.Log("copy from " + abInfo.FullName);
                    Debug.Log("copy to " + projectInfo.FullName);

                    File.Copy(abInfo.FullName, projectInfo.FullName, true);

                    string relativePath = BuildAssetBundleHelper.TrimToRelativePath(projectInfo.FullName);
                    AssetDatabase.ImportAsset(relativePath);
                }
                else
                {
                    File.Copy(projectInfo.FullName, abInfo.FullName, true);
                }
            }
        }
    }
コード例 #2
0
    public static List <string> GetSingleExcelResourcePaths(ExcelDirType dirType, string excelName)
    {
        string          resourcePath = _resourceDir + ExcelConfig.GetTopDir(dirType);
        string          excelPath    = Path.Combine(Application.dataPath, resourcePath);
        List <FileInfo> fileInfos    = GetUsefulFileInfosFromDir(excelPath);
        List <string>   paths        = new List <string>();
        string          prefix       = excelName + "_";

        foreach (var info in fileInfos)
        {
            if (info.Name.Contains(prefix) && !info.Name.Contains(".meta"))
            {
                string p = TrimToRelativePath(info.FullName);
                paths.Add(p);
            }
        }

        if (paths.Count == 0)
        {
            Debug.Log("Warning: GetSingleExcelResourcePaths is empty: " + excelName);
        }

        return(paths);
    }