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. Dismiss Notice

Question How do I define build paths?

Discussion in 'Addressables' started by led_bet, Mar 4, 2021.

  1. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    I'm getting up to speed with Addressables and one area that I cannot wrap my head around is how to properly define local and remote build paths. I have read the documentation about profiles & path syntax, which refers to a single build target variable and implies there are others, but I can't find any documentation about what these might be. I also see references in other threads about "defining your own runtime path variables"; how would one go about doing that? Is there a list of implicit build target variables somewhere? Ideally, it would be great to have a few code examples of common-case build path definitions.

    To add (though not totally relevant), my use case for addressables (besides memory management) is to import user assets that have been bundled via addressables from a separate project into my game.

    I'm a seasoned dev and this problem is making me feel real noobish lol. Any help/context would be greatly appreciated.
     
  2. AdminXRBASE

    AdminXRBASE

    Joined:
    May 19, 2020
    Posts:
    18
    I fully agree that this should be better documented. I am trying to figure this stuff out also, but it is documented in a very abstract way, while some examples would be very helpful in this area!

    So posting here to bump this topic up!
     
  3. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    After posting this, it dawned on me that these abstract path variables can be anything within the Unity API that qualifies a path. So, for paths that are resolved at build time, you can use any path variable within the UnityEditor API. For paths that are resolved at run-time, you can use the UnityEngine API.

    For example, I think it's accurate to say that path fields in the Application class can be used at build time or run-time. See 'streamingAssetsPath' or 'dataPath' properties:

    https://docs.unity3d.com/ScriptReference/Application.html

    Keep in mind that .net also has a convenient Path class that could be used to fetch and build paths for the custom-defined variables that get resolved at run-time:

    https://docs.microsoft.com/en-us/dotnet/api/system.io.path?view=net-5.0#fields

    I think the addressables documentation would do well to enumerate on this topic a bit more by pointing to APIs like those above and offering a one or two more examples. I think when trying to wrap one's head around profiles, schemas, asset groups, catalogues, local vs remote bundles, etc, it's easy to miss what seems obvious in retrospect haha. Especially so when one doesn't do a ton of path qualification in their day to day coding work.

    In any case, hope this helps. If I can help clarify anything, let me know.
     
    Last edited: Mar 23, 2021
    AdminXRBASE likes this.