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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Bug Pink materials when loading addressables from a CDN

Discussion in 'Addressables' started by abdo400, Oct 8, 2022.

  1. abdo400

    abdo400

    Joined:
    Feb 12, 2016
    Posts:
    44
    Hi,
    I am using addressables with Unity CCD to download my app assets.
    I have 2 prefabs. One has multiple models inside of it and one has references to other prefabs in its script. So in theory it should make all the referenced prefabs + models + textures addressables.
    But after loading the content from the CDN, I get pink materials.
    I deleted the prefabs from the scene after using them as addressables.
    I included all the shaders I am using in "Project Settings => Graphics => Always include" shaders.

    This is the code I am using
    Code (CSharp):
    1. private void LoadAssets() {  
    2.         m_SceneHandle = Addressables.DownloadDependenciesAsync(keys, Addressables.MergeMode.None);
    3.             m_SceneHandle.Completed += OnDownloadComplete;
    4. }
    5.  
    6.  
    7. ///
    8. private void OnDownloadComplete(AsyncOperationHandle obj) {
    9.             m_PrefabHandle = Addressables.LoadAssetsAsync<GameObject>(prefabs, OnPrefabLoaded, Addressables.MergeMode.Union, false);
    10.  
    11.             m_PrefabHandle.Completed += OnPrefabsLoadDone;
    12.  
    13. }
    14.  
    15.  
    16.  
    I am using Unity 2022.1.1f1 - Android
    Addressables 1.19.19
     
  2. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    One possible reason is that the graphical api of the shader was unsupported. If you were testing the Android's asset bundle on Editor, the shader would be pink. You need to use "Vulkan" for the Editor. It's a universal graphical api.
     
  3. wethings

    wethings

    Joined:
    Aug 26, 2018
    Posts:
    28
    Or try to force the renderer to reload the shader with
    Code (CSharp):
    1. go.GetComponent<Renderer>().material.shader=Shader.Find("Universal Render Pipeline/Lit");
    However, that didnt work for me when I did an Android build. My scene is actually empty except for a script to spawn in the addressable assets, so I just added just a dummy cube into the scene and it worked preventing the shader from appearing pink. I have no idea what is going on.
     
  4. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Hi are you trying to load Android bundles in the Editor? If so, then pink shaders are expected in this case. Bundles are platform dependent. I would only expect Android bundles to load correctly on an Android device.
     
  5. wethings

    wethings

    Joined:
    Aug 26, 2018
    Posts:
    28
    Yea I am loading android bundles on the android device.

    I wanted to submit a bug report but it is not consistent. With a fresh project it is fine but happened once or twice, with my current project happens all the time
     
  6. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    kmowers and abdo400 like this.
  7. wethings

    wethings

    Joined:
    Aug 26, 2018
    Posts:
    28
    Omg yes you are right, I totally missed this point.

    One last thing question, so setting it to keep all shaders works fine, but if I try to add the URP/Lit shader to the list of always includes shaders the build time really explodes into hours... is this correct?