Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question getFileUrl

Discussion in 'Web' started by Marks4, Mar 29, 2024.

  1. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    563
    PlayCanvas has a method to extract the url of a file under the Assets folder. Can Unity do the same or am I forced to use the StreamingAssets folder ?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,659
    Ideally avoid referencing by path but rather assign asset references in the Inspector. This is the default, recommended approach unless you have very specific requirements that force you to use a path. You may want to elaborate on what you're trying to do to get the recommended solution. ;)

    The only assets you can load (reference) by path are those under Resources and StreamingAssets.
    Resources assets need to be loaded with Resources class.
    Webrequest must be used to access StreamingAssets assets on Android and Web.

    Caution: All assets in either of these folders are always included in a build, whether you use them or not.
     
    Marks4 likes this.