Search Unity

Can an Adressable Asset in a project refrence a Adressable Asset create from an other project ?

Discussion in 'Addressables' started by Kiupe, Aug 28, 2018.

  1. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hello,

    I was wondering if I can create an Adressable Asset from a project A and then reference that Adressable Asset as an "local" Adressable Asset inside a project B ?

    The idea is to have a main project that can load/stream mini-games. In order to ease the development each mini game would be developed in its own Unity project. I'd like all min-games to be already in the main project so local Addressable Assets sound good. But is it possible to create an Addressable Asset from a mini-game project and then move it to the main project and having it considered as local Addressable Asset ?

    Thanks
     
  2. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Sorry to bump that post but I really need to figured out if that's possible or not. Maybe @unity_bill could help me out on this one ? ;-)

    Thanks
     
  3. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    This is a workflow we intend to support. We have some things in place to handle it now, but they are not yet documented or fully fleshed out. I will try to put together some more detailed notes on this next week to post here.

    -Bill
     
    leollama and SugoiDev like this.
  4. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    That's great news. We really see Adressable Asset as a solution to separate really different part of big project. I will wait for further information about this.

    Thanks !
     
  5. PaulBurslem

    PaulBurslem

    Unity Technologies

    Joined:
    Oct 7, 2016
    Posts:
    79
    Hi, Addressables has an API to load additional catalogs from a settings.json file:
    public static IAsyncOperation<IResourceLocator> LoadCatalogsFromRuntimeData(string runtimeDataPath).
    This is the file generated into the streaming assets folder that contains the runtime settings for the Addressables system. You would need to copy this file (renamed) from your secondary project into your project that builds the player and load it manually after the original one loads.
    Something like this should work:

    Addressables.InitializationOperation.Completed += op => Addressables.LoadCatalogsFromRuntimeData("othersettings.json");

    We are also thinking of ways to make this process a bit more straightforward so we welcome your feedback.
     
    gawoon and EirikWahl like this.
  6. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Thanks for the detailed explanations. So if I get it the right way, in that case an "other project" Adressable Asset could not be directly referenced in another project. I mean, using a drag & drop inspector field but instead use a string to reference the asset name/adress. Is that right ? If so, I think its totally acceptable but more straightforward process will be welcome :)
     
  7. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hello,

    @PaulBurslem I'm not quite sure to understand what you explained.

    I do not want to download an AddressableAsset from an other project, I think I really badly explained my need. I want to be able to create an AddressableAsset from a project A and then make this AddressableAsset available in a project B. It would be more like be able to move the asset and added to an other project and then add it to a group.

    Otherwise I do not understand how an AddressableAsset created from a project A can be available in a project B, except if it's a remote AddressableAsset but if I want it to be a local asset it should be present in the project, right ?

    Thanks
     
  8. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    So @unity_bill any news on that feature ? :)
     
  9. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hello @PaulBurslem ,

    I'm not sure where I should copy-paste my settings.json files. After building my Unity project and opening the content I have the following structure:

    Capture d’écran 2018-09-25 à 14.35.38.png

    In the project in which I want to load this catalog, what files/folder should I copy and where ? I tried to copy-paste the StreaminAssets folder and put it in the Assets folder on my project and renamed the settings.json into settings2.json.

    Then I put a script with the following code :

    Code (CSharp):
    1. public class LoadCatalog : MonoBehaviour {
    2.  
    3.     void Start () {
    4.  
    5.         Addressables.InitializationOperation.Completed += OnInitializationComplete;
    6.     }
    7.  
    8.     void OnInitializationComplete(UnityEngine.ResourceManagement.IAsyncOperation<IResourceLocator> op){
    9.  
    10.         Debug.Log("OnInitializationComplete");
    11.  
    12.         string settingpath = Application.streamingAssetsPath + "/com.unity.addressables/settings2.json";
    13.  
    14.         UnityEngine.ResourceManagement.IAsyncOperation<IResourceLocator> catalogOp =  Addressables.LoadCatalogsFromRuntimeData(settingpath);
    15.  
    16.         catalogOp.Completed += CatalogOp_Completed;
    17.     }
    18.  
    19.     void CatalogOp_Completed(UnityEngine.ResourceManagement.IAsyncOperation<IResourceLocator> obj)
    20.     {
    21.         Debug.Log("CatalogOp_Completed - status: " + obj.Status);
    22.  
    23.         Addressables.Instantiate<GameObject>("MyButtonPrefab", this.transform);
    24.     }
    25. }
    Result:
    - obj.Status returns true
    - "MyButtonPrefab" which is an AddressableAsset for the recently loaded catalog is never instantiated.
    - I don't know why but after some editor navigation manipulation (click a tabs etc.) the StreamingAssets is magically destroyed !


    Thanks
     
  10. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    Sorry to bump that post but still trying to figure out how to achieve that. It would be really useful to reference other project addressable assets. It would allow to have specific Unity project to specific modules and a main project able to load ( reference ) those modules.

    @unity_bill any any news regarding that workflow ?

    Thanks
     
  11. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    This could be solved nicely if you could extend the system to allow dragging things from Packages tree in Project pane to Addresables panel and make the generated path dependent on package name. UPM is already a good cross-project code sharing tool.
     
  12. Kirsche

    Kirsche

    Joined:
    Apr 14, 2015
    Posts:
    121
    Has anyone managed to get this to work? I think I've exhausted all possible path combinations (relative and absolute) but Addressables.LoadCatalogsFromRuntimeData always returns AsyncOperationStatus.Failed. :(
     
  13. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    I still don't have. Unity members are pretty much quiets lately, maybe they are busy (Unite ?) or in vacation or something else.

    I guess we have to be patient and to wait :)
     
  14. GilesCoopeAkelius

    GilesCoopeAkelius

    Joined:
    Oct 2, 2018
    Posts:
    7
    We need to be able to build these catalogs and bundles independently from building the entire project. Then we want to selectively load a .json file and add the items contained to the current Addressable Catalog at runtime. Is this currently possible?
     
  15. Kirsche

    Kirsche

    Joined:
    Apr 14, 2015
    Posts:
    121
    I've just tested it with the new version. However the problem still persists in 0.4.6-preview.
     
  16. Murcho

    Murcho

    Joined:
    Mar 2, 2009
    Posts:
    309
    I'm not sure if you saw my thread, but I've managed to build asset bundles in one project and load them in another, but it's very clunky. This was done with the 0.3.5-preview version however, so I'll be moving to the 0.4.6-preview version this week to try and improve the flow with that.\

    EDIT : Forgot to include the actual thread I was talking about https://forum.unity.com/threads/gen...parate-project-for-multiple-platforms.567151/
     
  17. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Do you have news about this workflow ? It would really help to not clutter a single project containing many games.

    Thanks
     
  18. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @unity_bill We also would require this functionality. Otherwise we have to include all potentially loaded scenes into our main project would become huge. We are talking about 400 scenes à 100MB-500MB incl. lightmaps, etc (planned - not realized yet because currently this seems not to be easily possible).

    It would be really nice to be able to load those by loading all settings.json of each of the 400 projects and keep each of those scene in a different unity project.
     
  19. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Looking over this whole thread, sounds like some parts may be broken, and some may just need clarity. The part I know needs clarification... the idea is that you'd have some main base project "ProjectHome", and some other projects with assets, "ProjectOther". You would use addressables to have access to some assets in ProjectOther via a string address (no direct ref), and would use addressables to build those assets into asset bundles. From there, you should be able to either put all those bundles online to load them from ProjectHome, or put them into StreamingAssets in ProjectHome to load them.

    But, it sounds like people are running into bugs, and this is a workflow we have not fully vetted. So in the coming months, we'll plan to work out a sample that demonstrates (and tests) this.
     
    Kiupe and MNNoxMortem like this.
  20. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    Oh yeah! That would be soooo awsome. Also because we are running into the simple problems of huge unity projects, huge repositories (even when git lfs), and that would help so much to solve all that.
     
  21. adrian-blackboxrealities

    adrian-blackboxrealities

    Joined:
    Nov 15, 2018
    Posts:
    1
    Is there any update on this feature?
     
    EirikWahl likes this.
  22. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    The update is that our initial test projects are working, but we have not yet made something robust enough to be a sample project. We have other simpler sample projects coming soon, but have this on our list once we get into the complex samples.
     
  23. SReplyR

    SReplyR

    Joined:
    Jan 4, 2019
    Posts:
    12
    https://forum.unity.com/threads/loa...ut-importing-the-content.656503/#post-4432837

    i found a solution for this one.

    The problem comes with the naming of the json file because it has to be called through string and at the moment there is no system (which i noticed) to force the Addressable to build the json with a different name than "catalog.json".

    I haven´t tried to change the name to see what happens, i just figured out that the "settings.json" created with the catalog reflect that naming. So it´s still an open question (from my point of view) how to setup multiple Addressables from multiple projects and to have a coherent "settings.json", but this will be the next step of my experiments, and i don´t exclude that some future improvements in the feature might make this step easier and clearer in some way.
     
  24. jterry

    jterry

    Joined:
    Oct 30, 2014
    Posts:
    9
    I'm trying to load multiple projects' addressables in a 'home' project. I have an almost working example where I used the examples found in this thread and in a couple of others.

    I end up with Addressables.ResourceLocators being populated with the correct data (two indices in my case). However, I can only get the first catalog I try to load to work, after loading the first asset, the second bundle will not work. However, if I replay and try to load the 2nd catalog first (opposite of step above), it now loads, but now the other asset will not load.

    To me it looks like the Addressables.LoadAssetAsync<GameObject>('name') only looks at the first index of Addressables.ResourceLocators.
     
  25. EirikWahl

    EirikWahl

    Joined:
    Apr 7, 2018
    Posts:
    21
    We are experiencing a similar issue. It seems that there is a bug in Addressables version 0.8.6 that will load a resource from the wrong asset bundle if the resources themselves (not the addressable address) have the same path/name in the Unity project, and another resource with the same source path/name has been loaded from another catalog first. The workaround for us is to ensure that not only the addressable address (key) is different, but also the asset path/name in the Unity project must be different.

    (PS: I assume you remembered to call `Addressables.ResourceLocators.Add(resourceLocator);` after `Addressables.LoadContentCatalogAsync(catalogPath);` finished.)
     
  26. SagiMiller

    SagiMiller

    Joined:
    Sep 18, 2019
    Posts:
    1
    Hi, i also have a single project containing many games.
    And i want each game to be downloaded in runtime with addressables as a single scene.

    The issue is that each game uses a shared-code-submodule
    And you cannot have in a 2 identical .cs files in a project

    I want the games to be independent, so if i now add a new game, and modify the shared-code-submodule
    I can keep my old games "as is" and do not update them to the latest shared-code-submodule

    Cant figure this out myself, thanks
     
  27. calc1fer

    calc1fer

    Joined:
    Oct 5, 2019
    Posts:
    62
    [/QUOTE]
    Hi,
    Then, how can I load link.xml?

    1. Will settings.json load link.xml too?
    2. Is link.xml an essential asset for using addressables?

    Thanks.
     
  28. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Hi,

    is there now a more reliable way to manage multi project addressables?

    Maybe defining a resource that just have a remote catalog or something like that without having to copy all the files?

    I mainly want to use the catalog update api.


    My usecase is that we have two projects.
    The main project is a Productconfigurator that uses the assets from the second project. The second project just handles the assets and builds remote assetbundles and updates for that.

    On startup, the Productconfigurator checks the fileserver for catalog updates and therefore new assets.

    Currently I manage this by copying the addressable files from
    Asset Project\Library\com.unity.addressables\StreamingAssetsCopy\aa\Windows
    to
    Productconfigurator Project\Library\com.unity.addressables\StreamingAssetsCopy\aa\Windows

    But it would be nice if I could just define a remote loading path in the addressable editor without copying files between projects.
     
  29. SReplyR

    SReplyR

    Joined:
    Jan 4, 2019
    Posts:
    12
    I personally opened this thread: https://forum.unity.com/threads/loa...project-without-importing-the-content.656503/

    It was April last year, and i was able to use it for a single addressable source. I honestly gave up to use this in production since then, today it comes a moment where i might be forced into this approach, but i see that not much really improved unluckily. For product configurators is essential to have the content hosted in side projects, or within a couple of products featured (especially if we talk about automotive) the project becomes huge to check out and to be managed. I´m kinda disappointed about this after all this time passed by.
     
    Twyker, MNNoxMortem and pahe like this.
  30. crawfis

    crawfis

    Joined:
    Jan 30, 2014
    Posts:
    114
    Solved (somewhat). Unity 2020.2.a10, Addressables 1.8.4
    This is being advertised in much of the Unity presentations about Addressables, but no tutorials (as well as many other use cases they only talk about). Let me see if I can provide another example (one Unity talks about). We have a group A (mainly artists) working on assets, and then we have a group B (mainly programmers) working on a game. Group B can start with cubes, or prototypes. Periodically we want to merge the results from Group A into Group B. Ideally this would be a "built" set of packed Asset groups. However, I would be happy to just copy the asset folder (or export Group A's work as a package and import). I have tried both. Both of these indicate that there are no settings and we need to create one. Clicking on Create a Group gets your in the door of Addressables, but no errors and does not work. Importing is the same. The prefabs come over fine and are marked as addressable. The Groups are even there and seem to be fine, so ... What is required is not entirely sure. I thought you had to select the group, In the Play Mode Script, select the "Use Existing Build". This worked and then didn't. So, build the group and try that. If not, I found the combo build and use existing to work. So new project and another test:
    • Group A Initial Set-up (done my either group)
      1. Install the Addressables Package
      2. Create Addressables
      3. Create Groups
      4. Add Lables, ...
      5. Select the Group(s) you want to export in the Project Window. for example, the group "Debris"
        • AddressableAssetsData/Groups/Debris.
      6. Build the groups (in Addressables Group window) Build->New Build->Default Build Script
      7. Right-click and select "Export package ..." and follow instructions.
        • Warning: Unity likes to export all scripts that are not Monobehavior (and maybe those as well). Uncheck those if you want, otherwise include the dependencies.
        • Warning, do not use Assets Menu for this.
    • Group B Initial Set-up
      1. Install the Addressables Package (need to test whether this step can be skipped - yes it is required)
      2. Open the Addressables->Groups window
      3. Create the AddressableAssetSettings.
      4. Import the package you created above from Group A.
      5. Select the import groups "Debris"
      6. Do a new Build on this.
      7. (optional?) Select the Play Mode menu and the "Use Existing Build" option.
    • Group A workflow.
    1. Change the assets, add to them, etc.
    2. Save the scene / everything.
    3. Build the group.
    4. Export to a package as above. (This fails!!!! New assets are not included!)
      1. Tried using a "Clean" build (misnamed) followed by a new Build.
      2. Tried many other incantations.
      3. Also in the new project, selecting the Debris.asset Group and trying to export does not include any assets.
      4. So, I guess you need to export the entire project :-(.
    • Group B Workflow
      1. Import new / updated package.
     
    Last edited: Jun 2, 2020
  31. crawfis

    crawfis

    Joined:
    Jan 30, 2014
    Posts:
    114
    FYI. I tried copying the Built Streaming Assets folder over, but when you hit play in the editor you get a message that Unity is "Deleting Addressables data from ..." and lists the streaming assets folder. I guess the only way this works is to copy all of the art assets over. Any advice @unity_bill ?