Search Unity

Getting all 'original' folders within Resources in a build

Discussion in 'Scripting' started by Deleted User, Nov 30, 2015.

  1. Deleted User

    Deleted User

    Guest

    Hey folks,

    to make life a bit easier for myself I wrote a script, which on start loops through all the folders in the Resource folder (using DirectoryInfo) and saves the name and path off the assets found. This way I can easily load assets simply by giving a name and a type (the script knows the saved path, and casts it to the correct type).

    Whenever I make a build however, the script doesn't work since all the data in the Resources folder gets put in one single asset.

    So theres my question, is there any way to loop through all assets, and save the paths within a build?
     
  2. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Use your same DirectoryInfo process to write the paths to a text file that ships with your build. At runtime read the text file instead of the directories.
     
  3. Deleted User

    Deleted User

    Guest

    Thanks! I decided to try your way, and even though it feels a bit hacky it works.
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,528
    Here's the way you can look at it.

    If there is a method/function out there that returns some data. Well that data had to be located somewhere for it to be queried from.

    So if it's not you storing that data, it would have been unity storing that data.

    Why is it hacky for you to store it, but not hacky for them?

    Unless you mean you think your storage mechanism isn't optimized enough... but in that, I'd say. Isn't it unoptimized to store the data in a generic term (unity doing it for you) if the majority of users don't need it?

    Here's the first level of optimization for data. Only store the data you need.