Search Unity

Can someone explain streamingassets...?

Discussion in 'Editor & General Support' started by TOES, Feb 20, 2020.

  1. TOES

    TOES

    Joined:
    Jun 23, 2017
    Posts:
    134
    I am making an Unity application that dynamically loads various files, and I have put those in streamingsassets. Everything is working well, but I wonder, why does Unity "import" files I put here?

    Isn't the whole point of streamingassets to leave the files alone, without processing them and just let the app read the raw untouched files directly?

    It's becoming a problem in my case, as I often regenerate the streamingassets content, and Unity can spend as much as ten minutes for whatever mysterious business it is doing when detecting something changed and deciding it has to "import". It also clutter the streamingassets hierarchy with unwanted .meta files, so that I need to clean it up with a script after deployment. I know why it is necessary with .meta files in other folders, such as Resources, but again it makes no sense to me to put those in streamingassets.

    Can anyone explain to me why Unity needs to "import" files put into this folder? And is it possible to tell it to leave it alone?
     
    Xarbrough likes this.
  2. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I’d also be interested in the official Unity explanation, but I assume it might be just incidental or because of a few otherwise convenient fearures: 1) It’s possible to reference assets from the Streaming Assets folder as TextAssets in editor scripts. 2) You can write custom inspectors and importers for these files. So it might just be that Unity wants to allow for these special cases.

    On another note, I don’t think that the import of StreamingAssets should take up much time. Unity only generates meta files for these assets and adds them to the database. There is no processing going on, so it should be very fast. For example, we generated thousands of small files in StreamingAssets and it took only a few seconds.
     
  3. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
  4. TOES

    TOES

    Joined:
    Jun 23, 2017
    Posts:
    134
    Thank you for that link. I think I have read this page multiple times before, but I just noticed Unity will ignore files starting with a dot or ~, so I can try name a folder inside streamingassets something like .root and hopefully Unity will ignore it's content while I still get the convenience of having access to the path location using Application.streamingAssetsPath, which is useful as you can never predict exactly where it will end up on various platforms.