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

Addressables in Custom Packages?

Discussion in 'Package Manager' started by twinklapps, Mar 2, 2021.

  1. twinklapps

    twinklapps

    Joined:
    Feb 6, 2018
    Posts:
    8
    Hi,

    My team are currently trying to create a custom unity package which will contain addressable assets that can be pulled into various other unity projects. We would also like to manage the addressable assets from within the custom package as an embedded package using git submodules, Is this possible?

    We’ve currently tried copying the AddressableAssetsData folder from a project into our custom unity package along with all the assets that were part of the addressable group. We selected Manage Groups in the Addressable Asset Settings and this just shows an empty window even though we can see the data for the addressable asset groups we have created in the assets folder.

    We noticed that as part of the custom package layout: https://docs.unity3d.com/Manual/cus-layout.html there is no mention of addressable or anywhere else in the custom package manual pages. This surprised me with this being the main/preferred way to load assets within unity.

    On top of this there is also no Plugins folder which would have helped for plugins that contain both editor and runtime scripts, in this case I separated the plugins manually myself.

    It seems like a couple of people are trying to do something similar but there doesn’t seem to be any answers as of yet to whether this is possible, if not is there a good reason why it isn’t and will this feature become available in the future? I couldn’t find any forum that relates to this current topic.

    Thanks,

    Twinkl Apps Team
     
  2. Davidtr_Unity

    Davidtr_Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    34
    Hi twinklapps,

    A recent issue seems to be causing the empty group window in the Addressables package. It should be resolved as of the 1.17.0-preview version.

    > We would also like to manage the addressable assets from within the custom package as an embedded package using git submodules, Is this possible?

    You can develop and manage the addressable assets while the package is embedded, yes. Embedding a package to modify it is the recommended way to develop your package, as explained here. I think you can have the embedded package be a git submodule in that context, I am not aware of anything that would trip the package manager in that regards, though I have not tested it myself.

    > On top of this there is also no Plugins folder which would have helped for plugins that contain both editor and runtime scripts, in this case I separated the plugins manually myself.

    This is an optional convention, you can make a plugin folder if you need to.

    Managing your addressables in a package sounds like a good idea and, as far as I know, it should be possible with what we currently have. Let me know how it goes so I can be of assistance.
     
  3. twinklapps

    twinklapps

    Joined:
    Feb 6, 2018
    Posts:
    8
    Hi Davidtr_Unity,

    We have updated to the 1.17.0 preview version. I can now see the groups as you suggested.

    However I have noticed addressables seem to be created directly under the assets folder in a folder called AddressableAssetsData.

    I moved this folder into my embedded package runtime and this worked as expected within my package development Unity project.

    Embedded_Package_Addressables.png

    However when I pull the package via git remotely, this seems to lose connection to all of the addressable assets data even though the folder can be found in the package runtime folder. When attempting to open the Addressable Group in the new project it asks you to create addressable settings. Which then creates a folder called AddressablesAssetsData under the Assets folder in the new project I am trying to use my custom package with addressables. It seems to want the Addressables data in this specific folder location, I may be wrong about this?

    Git_Package_Addressables.png

    In the future I can see our unity project needing to contain 2 lots of addressable data. One for the custom package and one for the actual project. Can you see any issues with this workflow, or do you know if there is a better way to achieve this goal?

    For now we only need one custom package to contain addressables as 2 of our different apps will be using this same addressable content. Same as above, do you see any issues with this workflow, or do you know if there is a better way to achieve this goal? For these apps we current want to keep all of our assets offline and is a current business requirement until the apps grow larger, so we currently don't want to use and CDN approaches but can imagine this being useful in the future.

    I've noticed someone else seems to be having a similar issue: https://answers.unity.com/questions/1750028/how-to-combine-custom-package-addressables.html.

    Thanks,

    Twinkl Apps Team.
     
  4. Davidtr_Unity

    Davidtr_Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    34
    Hi twinklapps,

    You are correct that moving the "AddressableAssetsData” folder to a new project does not work right off the bat. I just found out that the "AddressableAssetsSettings" scriptable needs to be referenced in the “EditorBuildSettings.asset” file in order for the folder to be recognized.

    This suggested solution does not work. Please don't do this and keep reading on the rest of the thread for more informations.
    To make this work, you will have to open the file “ProjectSettings/EditorBuildSettings.asset” located in your package project, copy the line which begins with “com.unity.addressableassets” (including any indented line under), and paste it in the same file located in your target project.

    Here’s what the entry that needs to be copied looks like on my computer :
    Code (CSharp):
    1. com.unity.addressableassets: {fileID: 11400000, guid: c20ab48b753e40c40914d59e5e8404f8,
    2.       type: 2}
    ^Please note that the fileID and guid in my example won't match those in your project.


    > In the future I can see our unity project needing to contain 2 lots of addressable data. One for the custom package and one for the actual project. Can you see any issues with this workflow, or do you know if there is a better way to achieve this goal?

    I am not sure if this is possible. Unity projects seem to be able to reference at most one “AddressableAssetsData” folder. You might want to ask this at the folks over on the addressables forum.
     
    Last edited: Mar 15, 2021
  5. twinklapps

    twinklapps

    Joined:
    Feb 6, 2018
    Posts:
    8
    Moving Addressable Assets Data Folder

    The process you suggested is apparently not fully supported . I’m guessing this is a unique edge case I’m working with even though it seems like everyone should be using this workflow.
    https://forum.unity.com/threads/moving-addressableassetsdata-folder.729239/

    Just to go over the steps I have followed:
    1. My textures are stored in the embedded package within an overall project. I create an addressable group for these and this was by default saved out to the Assets folder in the main unity project. As suggested in the documentation: https://docs.unity3d.com/Packages/c...manual/AddressableAssetsDevelopmentCycle.html
    2. I moved the AddressableAssetsData folder the Assets folder to my embedded package runtime folder.
      • These addressables still work as expected now the folder location has been changed. And when cleaning and building the addressable content I can confirm they are placed correctly under the AddressableAssetsData folder within my embedded package runtime.
    3. I committed all these changes to the embedded project to my git submodule. I then committed the whole project to my overarching git project that contains all my embedded unity packages as git submodules.
    4. I pull my embedded project via git (the submodule repo) to my new project that I need these new addressables content.
    5. I copied the 2 lines as specified from the file ProjectSettings/EditorBuildSettings asset my initial project where I create my embedded packages.
    6. I replaced the 2 lines in my new project where I am pulling my embedded package via git.
    7. I confirmed these 2 lines are exactly the same in both projects and this workflow still doesn’t work.
    8. When trying to open the Addressables Group it tells me to Create Addressable Settings. Also, selecting on the Addressable Asset Settings in the Runtime AddressableAssetsData folder it appears to be locked off/greyed out:
      • Screenshot 2021-03-09 at 21.53.56.png
    9. I checked my texture file and it is no longer marked as addressable:
      • Screenshot 2021-03-09 at 21.56.05.png
    10. I checked my scriptable object that contains a link to the sprite addressable asset reference and although it can knows about the sprite it has lost connection to addressables. I feel we are so close but there may be something small I am missing.
      • Screenshot 2021-03-09 at 21.56.20.png

    I would also ask if we do get this working, is it possible for unity to update this manual page, I think this information could be useful for people for future reference.
    https://docs.unity3d.com/Manual/upm-assets.html

    PLEASE NOTE: For some reason your process worked when bringing the assets and addressables across when exporting the assets into a package using the unity editor and the importing them into the project. Obviously this process will not be good enough for us as we will need to make many changed in the future to this base package and would ideally use the git packages through the package manager.

    Project containing more than 1 AddressableAssetsDataFolder
    I personally think this is a much needed workflow, unless we are overcomplicating this system and there is a much better way to go about it.

    Is it ok if I contact the someone on the Addressables forum and tag you and this forum post in the new forum. Hopefully then we can get to the bottom of this working across all teams. As I believe this may be a workflow that the Addressables team have not through about with working with Custom Packages and focusing more on just a single unity project. The reason I think this may be the case is seeing in this blog post https://forum.unity.com/threads/moving-addressableassetsdata-folder.729239/ they are thinking of putting the ‘analyze rule data’ in the library data. Although I don’t know much on this area I’m presuming if we have 2 states of Addressable Assets Data in a project we may need 2 locations for the analyse rules data in case they are different?

    Thanks,

    Twinkl Apps Team
     
    Last edited: Mar 9, 2021
  6. Davidtr_Unity

    Davidtr_Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    34
    Thank you for sharing the detailed reproduction steps.

    You are correct that modifying the project file directly is not officially supported; I suspected that this could have been an easy workaround, but I guessed wrong. I’ll edit my previous answer since it is misleading.

    I found the correct approach, Addressables Groups can be imported from packages as of Unity 2020.2.0a9 and Addressables package version 1.16.13.
    The missing bit is to only include the group asset and its respective schema assets in your package, and to make sure that the project in which you are going to import the package already has a default "Addressables Settings" object before importing your custom package. In other words, you still need to have the “AddressableAssetsData” in your package, but you should only include the “AssetGroups” folder underneath, the rest must remain at the project level.

    Preparing the project in which you will import the package is simply a matter of making sure that the Addressables package is installed, and to create the Addressables Settings if not already present. Users have reported that the order of operation here is very important, this has to be done before you import your custom package, or the groups will not be recognized.

    Finally, you can import your package with the Addressables Groups. This should import the groups automatically and make them visible in the Addressables Groups window.

    > I would also ask if we do get this working, is it possible for unity to update this manual page, I think this information could be useful for people for future reference.

    Absolutely, I will make sure we add an extra entry for Addressables.

    > Is it ok if I contact the someone on the Addressables forum and tag you and this forum post in the new forum.

    It is totally fine, I will also wait for your answer and raise this thread internally so that they have a chance to see it.
     
    Last edited: Mar 15, 2021
    voxelltech likes this.
  7. AdamBebko

    AdamBebko

    Joined:
    Apr 8, 2016
    Posts:
    161

    Requiring this prior step will be a big hurdle for distributing packages like this to the masses. I included com.unity.addressables as a dependency in my package.json. This neither generates nor imports the group. It would be much cleaner to have it automatically generate the settings when addressables is listed as a dependency and handle the group import automatically. Or at the very least prompt the user to do so, similar to how text mesh pro prompts the user to install "essentials" (although this also requires a package reimport too...) .
     
  8. danielaquestions

    danielaquestions

    Joined:
    Nov 4, 2021
    Posts:
    9
    Is the process the same if I only want to include the Addressables data inside a sample of a package? For example: my package has an Addressables dependency as the code uses Addressables but only a sample inside the Samples~ folder needs AddressableAssetsData. Because only the sample has actual assets marked as addressables, the package itself only contains code.

    Feels a bit weird to put the AddressableAssetsData folder in Runtime if the user never installs a Sample that requires that folder?