Search Unity

How to prove the asset was downloaded from remote

Discussion in 'Addressables' started by DeanGiddy, Jan 28, 2019.

  1. DeanGiddy

    DeanGiddy

    Joined:
    Oct 30, 2018
    Posts:
    10
    We have a project where there is a bundle group with its build and load paths set to remote build and load paths. The results of the asset build are uploaded to our web server www.xxx/folder/ resulting in our remote load path being www.xxx/folder/Standalone64.

    Our use case is that we want to be able to download the assets from the server even though the original asset does not exist in the build. When we delete the addressable asset from the group

    Code (CSharp):
    1. Addressables.Instantiate<GameObject>(address)
    will throw an InvalidKeyException. Makes sense, because the key/address is no longer in the asset bundle group because the group is now empty.

    However, if we simply make a prefab of an empty gameobject, make it addressable in the same group and give it the same address/key (effectively replacing the asset with a new one) the empty game object will be instantiated despite the fact that on our server we still have the bundle of our original prefab which was given the same address and our group's load path is correct.

    This basically proves that we were never downloading from the server in the first place.

    How can we be sure that our asset bundle is actually being downloaded from the server and is it possible to download a remote asset without needing the original asset included in the group in the editor.

    We have also tried using

    Code (CSharp):
    1. Addressables.LoadCatalogsFromRuntimeData(catalogPath).Completed += LoadCatalogsCompleted;
    where catalogPath is the exact path to our catalog.json hosted on our web server.
     
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    I'm confused. Your setup is:
    -someGroupSetupForServer
    -- assetX

    so you do a build, assetX is put in a bundle, you put the bundle on the server. At this point, LoadAsset("assetX") should work, and should download.

    Where I'm lost is that you're then deleting the asset from your group? Why are you doing that?
     
  3. DeanGiddy

    DeanGiddy

    Joined:
    Oct 30, 2018
    Posts:
    10
    So our issue was that our server (on azure) required a web.config file that defined how to process .hash, .json and .bundle files.

    We were deleting the asset from the group locally because we wanted no trace of the original asset in the project folder when downloading assets. And it works! But now we have a slightly more complicated issue. Our end goal is for a standalone application to be build with an empty group and that other developers with their own project folders can build their own asset bundles to be uploaded to the same server and our database would log the asset's catalog path and address name.

    What we found is that the addressable system's player cache will only recognize bundles created in the most recent build from that specific project. For example, in my first build I could build a group with an orc enemy that was given the address "Enemy". But a later content build with a mage prefab marked with the same address instead of the orc, the mage asset will be the one to be downloaded from the server through the address "Enemy" even if both bundles are there with their catalogs. This told us that the system prioritized the latest build. Fair enough.

    We tried the same thing again but with both prefabs having two different addresses. So actually addressing them as "Orc" and "Mage" but still creating them in separate content builds one after another where the asset group only contains one of those prefabs each time because our end goal requires that builds of individual assets can be made in isolation from each other.

    When trying to load the Orc prefab again, this time with its unique address, the application didn't recognize the key but it would recognize the Mage address and therefore load it. Even when trying to load the orc's catalog during runtime, we still could not load the orc prefab by it's address. Only the mage.

    Is it possible to extend the runtime catalog of assets with asset bundles of prefabs created in isolation from both one another and from the application project itself?

    Our use case for this is an app that contains no models, presents a list of assets available on the server through checking our database, and loading a selected asset. The assets themselves may be created by our team or another team in a different region, but we would still upload the asset through a web portal to add it to both our server and our database so that during application runtime, we can point the app to any one of these foreign addressable assets. Can this be done? Are their any workarounds with getting this to work?
     
  4. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    If you're talking about internally having multiple Unity projects, and loading multiple catalogs, we do have support for that. It's not really documented, but that's on the list to document and/or have examples for soon. The short version is you have to have each unity project create it's own catalog, then have a master unity project that understands how to load multiple catalogs. We have a couple known bugs for this in 0.5.3 that should be fixed in the next release.

    If you're talking about catalog hacking for the purpose of user modding, that's another story. That too is doable, but is uncharted & undocumented territory. Unfortunately the only advice I can give here is to poke around in our code to see what you can learn. If you are not already familiar with asset bundles, how they work, and their limitations, it will probably be quite difficult to do.

    -Bill
     
  5. sandeepsmartest

    sandeepsmartest

    Joined:
    Nov 7, 2012
    Posts:
    138
    How do i download asset bundles manually?I dont want addressable system to download the assetbundle automaticaly (with the help of remote catalog) .Assume i have a xml file in the cloud which tells me the assetbundle name or asset bundle path.As soon as i open the game i would query the xml file for the assetbundle name and then i would download that specific assetbundle on demand.I was doing this easily using legacy assetbundles but it looks little tricky with this addressables system.Any Ideas or Hints??Thank you
     
  6. sandeepsmartest

    sandeepsmartest

    Joined:
    Nov 7, 2012
    Posts:
    138
    sorted!!Thank you guys. Ref: https://forum.unity.com/threads/change-remote-catalog-load-path-at-runtime.712052/
     
  7. sinaari

    sinaari

    Joined:
    Jan 28, 2019
    Posts:
    47
    I apologize but I was not able to yet find documentation and examples on any of these two stories. Could you please point me to where I can read about how do I do this properly? I am interested in both of the stories you have outlined.
     
  8. El-Echi

    El-Echi

    Joined:
    Dec 3, 2016
    Posts:
    4
    Have you been able to figure it out? I'm stuck on the same issue
     
  9. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Here's the documentation for handling multiple projects: https://docs.unity3d.com/Packages/com.unity.addressables@1.19/manual/MultiProject.html

    If the source project, lets call it Project A, has no Assets in it's Addressable Groups but you want to load assets built in other projects you'll want to use this workflow.

    Something that I don't think is called out in that doc is make sure your Project A build knows about any scripts that may be used in the other projects. Largely this workflow assumes your Project A is all/mostly scripts and ancillary projects contain only content (Textures/Meshes/FBX/etc.). It's not impossible to have those projects use scripts and it work in the Project A build, Project A just has to be able to know about those scripts at runtime.