Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Loading multiple catalogs each using builtin shaders

Discussion in 'Addressables' started by Azengar, Dec 16, 2019.

  1. Azengar

    Azengar

    Joined:
    Nov 20, 2016
    Posts:
    11
    I am trying to load multiple catalogs at runtime that each contain prefabs using different materials with the standard shader.
    Thus each catalog references once or multiple asset bundles + the 'unitybuiltinshaders' asset bundle.

    The problem with this is that loading the first catalog works fine, but subsequent ones cannot be loaded because 'The AssetBundle 'path to builtin shaders bundle' can't be loaded because another AssetBundle with the same files is already loaded.', which makes sense because I'm using the standard shader in all of my bundles, but I'm not really sure how to go about this.

    I'm aware of the fact that each of my asset has a dependency to the builtin shaders bundle but I'd like for a way to manually built the shaders bundle and then manually set it as a dependency to my addressables groups but I have absolutely no clue how to do this.
     
    EirikWahl and AskCarol like this.
  2. Litovets

    Litovets

    Joined:
    Sep 3, 2012
    Posts:
    20
    I guess you need to create separate group and put there all your shaders. Then another groups will not contains these shaders.
     
  3. Azengar

    Azengar

    Joined:
    Nov 20, 2016
    Posts:
    11
    Yes that's what I would do if I was able to build all my addressables from a single project, the problem is that I want users to be able to create mods by creating their own addressables builds and then share them online.

    Ideally, I'd like to find a way to build my addressables with the unitybuiltinshaders bundle but only load it if not already loaded.

    As a temporary solution, I downloaded the unity builtin shaders manually and included in my project & renamed the ones I need so that the shaders are directly included in the regular asset bundle and not a separate one, but I don't think it is an optimal solution.
     
    AskCarol likes this.
  4. EirikWahl

    EirikWahl

    Joined:
    Apr 7, 2018
    Posts:
    13
    I found a workaround for this: Before building the addressable asset bundles, I (programatically) create a new default addressable group (cloning the settings for the old one). I do this because the name of the unitybuiltinshaders bundle (in Addressables package version 1.6.2) is created from the GUID of the default group. When creating a new default group with a new GUID, the names will get unique.
     
  5. Thom_Denick

    Thom_Denick

    Joined:
    May 19, 2014
    Posts:
    11
    I'm actually working on this as well... The issue with this for me is that the shaders bundle is over 2MB and the asset I'm trying to download is only 400KB. So I want to actually share this shaderbundle among all my assets which all have different catalogs, and they will all point to the same path on the server.

    My current approach is:
    -Set up object to be uploaded in Unity (in a standalone item uploader project)
    -Programatically add the asset as an Addressable to a group.
    -Upload the files to a server.
    -Load in the Addressable via remote catalog in a the main game project.

    All of my objects use the same shader (Autodesk) with the same maps and settings, so I really want to load this in once. Is there a way to preload the shared roomassets_unitybuiltinshaders.bundle in my main app? Or ideally just have the shader I need only in the main project, disregarding the shader dependency in the bundle?
     
  6. Thom_Denick

    Thom_Denick

    Joined:
    May 19, 2014
    Posts:
    11
    My workaround for this was to save the texture maps to a custom script, then set the shader to null before building the addressables and uploading to the bucket.

    I have my client handle all the shader setup and texture assignment on its own. This seems to work pretty well. You do need to have a shared script between the uploader and the client, but I'm able to do that in this setup.
     
    EirikWahl likes this.
unityunity