Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Get the number of Directories in Resources on Build (GetDirectories() alternative)

Discussion in 'Scripting' started by CDAfonsoCl, Jun 15, 2021.

  1. CDAfonsoCl

    CDAfonsoCl

    Joined:
    May 18, 2021
    Posts:
    14
    Hi everyone!
    I'm trying to get the number of Directories on a specific path in Resources.
    Using GetDirectories().Length it works on the editor, but not on the build.

    Code (CSharp):
    1. DirectoryInfo dir = new DirectoryInfo(resourcesElementTypesFolder);
    2.             int dirCount = dir.GetDirectories().Length;
    A solution that works on windows standalone build should be fine.

    Thanks
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,735
    The resources folder no longer exists once you build. All resources therein are packed into efficient resource files.
     
    CDAfonsoCl likes this.
  3. CDAfonsoCl

    CDAfonsoCl

    Joined:
    May 18, 2021
    Posts:
    14
    Thanks! I decided to set the values manually.