0
void OnInputChanged(string searchString)
    {
        if (!string.IsNullOrEmpty(searchString))
        {
            foreach (var asset in AssetDatabase.FindAssets("*.cs"))
            {
                readTextFile("", asset);
            }
        }
     } 

I tried this :

foreach (var asset in AssetDatabase.FindAssets("*.cs"))

but it didn't find any .cs files to search in. I want to find all the cs files also in root and in all subfolders in the Assets.

This doesn't seems to work :

AssetDatabase.FindAssets("*.cs")
Daniel Lip
  • 3,867
  • 7
  • 58
  • 120
  • 1
    Can't you just use `var asset = AssetDatabase.FindAssets("t:script", null);` – TEEBQNE Jun 18 '21 at 00:52
  • If the goal is reading files(not as assets) you can also check https://stackoverflow.com/questions/9830069/searching-for-file-in-directories-recursively – MarkSouls Jun 18 '21 at 00:56
  • @TEEBQNE you suggest is almost the same as I did few minutes ago : string[] assetsPaths = AssetDatabase.GetAllAssetPaths(); the problem in both cases it's getting all the scripts or if later I filter only for cs files in the assets that are also in the unity packages. and Idon't want it to search/get the scripts in the packages. is there a way to tell it in the script to skip scripts/cs files that are in packages ? – Daniel Lip Jun 18 '21 at 01:06
  • @DanielLip The second parameter in the `FindAssets`, is the folder in which the search will start. Set it to the parent of your project's folders. It will skip all of the packages. I believe something along the lines of `("t:script", new[] {"Assets"})` should work. – TEEBQNE Jun 18 '21 at 01:09

0 Answers0