private bool FindConfigIn(string path, out TextureImportConfig tic)
 {
     string[] dirs = path.Split('/');
     // Start at length - 1 to skip the filename, and stop at
     // index 1 to avoid going beyond the Assets directory.
     for (int i = dirs.Length - 1; i >= 1; i--)
     {
         string   dir   = Join(dirs, "/", i);
         string[] files = Directory.GetFiles(dir, "*.asset");
         for (int f = 0; f < files.Length; f++)
         {
             tic = Load <TextureImportConfig>(files[f]);
             if (tic != null)
             {
                 return(true);
             }
         }
     }
     tic = null;
     return(false);
 }
Пример #2
0
        static public void GetFilesInFolder(Object target,
                                            string folderPath,
                                            ref List <string> foundFiles)
        {
            // Check if current folder has a config file
            string[] assets    = Directory.GetFiles(folderPath, "*.asset");
            bool     hasConfig = false;

            foreach (string asset in assets)
            {
                string path             = GetRelativePath(asset);
                TextureImportConfig tic = LoadAssetAtPath <TextureImportConfig>(path);
                // TextureImportConfig tic = (TextureImportConfig)AssetDatabase.LoadAssetAtPath(GetRelativePath(asset), typeof(TextureImportConfig));
                if (tic != null && tic != target)
                {
                    hasConfig = true;
                    break;
                }
            }

            if (!hasConfig)
            {
                // Get list of all textures
                string [] files = Directory.GetFiles(folderPath);
                foreach (string file in files)
                {
                    if (IsValidFile(file))
                    {
                        foundFiles.Add(GetRelativePath(file));
                    }
                }
            }

            // Get list of all sub directories
            string[] subdirs = Directory.GetDirectories(folderPath);
            foreach (string subdir in subdirs)
            {
                GetFilesInFolder(target, subdir, ref foundFiles);
            }
        }