Search Issue Tracker

Fixed in 5.4.0

Votes

116

Found in

5.1.3f1

Issue ID

722725

Regression

No

Materials lose reference to textures if loaded from Asset Bundles

--

-

How to reproduce:

1. Open attached project
2. Open scene Scenes/AtlasedSpriteParticleTest.unity
3. Go to Build/AssetBundle
4. Play the scene
- Note how the particles have no textures

Comments (34)

  1. marcopaivaf

    Dec 15, 2016 21:10

    Besides making sure that or Asset Bundle is built for your target platform, you need to make sure to clean the Asset Bundle cache from the previous time you downloaded it.

    I am using 5.5.0f3, and I always had this issue when using Asset Bundles. I fixed the issue today, by doing a couple of things:

    1. I made sure that the shader that I wanted to use was included in the Asset Bundle (I have a custom Standard Surface Shader);
    2. I made sure that I am building my Asset Bundle for my target platform (In my case, I am working on a Windows machine, targeting Windows 64);
    3. I included my custom shader to the "Always Included Shaders" list inside the Project Settings -> Graphics;
    4. I cleaned my Asset Bundle cache by running "Caching.CleanCache()" from an Editor script;
    5. Built Asset Bundle;

    Hope that helps someone =)

  2. ADaurio

    Oct 21, 2016 15:09

    This has not been resolved in Unity 5.4.

  3. CelitoOokaIsland

    Oct 18, 2016 15:08

    I'm still having this issue on Unity 5.4.1f1, I tried the workaround suggested by OMAR_UNITY, but no luck with it.
    Since this is a problem that only happens on the editor for me, one workaround that worked was to add some lines of code only for when in the editor, where the asset loaded from AB would have its shader re-set by its name:

    #if UNITY_EDITOR
    foreach(Material material in [rendererLoadedAssetBundle].materials)
    {
    material.shader = Shader.Find(material.shader.name);
    }
    #endif

    Maybe this issue is related to the fact that almost the same thing happens with sound sources loaded from asset bundles in the editor. They are loaded without errors, but their references to the audio mixer groups are broken, even though the naming of the references looks correct.

  4. Omar_Unity

    Oct 16, 2016 17:18

    Hi, there is a possible workaround, of course, it depends on the origin of the issue every one of you is having.

    You may want to take a look at this article: https://support.unity3d.com/hc/en-us/articles/208380753-Shaders-are-pink-when-loaded-from-an-AssetBundle

    Cheers!

  5. bearxiong

    Oct 10, 2016 13:12

    This is not resolved. Still exists in 5.4.1f1

  6. Anemor2000

    Oct 03, 2016 18:55

    This is not fixed in 5.4....

  7. Klaus-Eiperle

    Sep 26, 2016 16:41

    Still there in Unity 5.4.1p2. I still need to reassign all custom shaders after loading an AssetBundle with WWW. I built the AssetBundles in the OSX Editor and when I test the built game, the shaders are not loaded. The same project in a Windows Unity3D 5.4.1p2 editor shows the same problem. I can reassign the shader by hand and then all the other objects which are using the same custom shader are fixed at once. :-(

  8. schetty

    Sep 26, 2016 07:29

    i have exported the assetbundle(.Unity3d) from Unity5.3.5, when i import into the file in Unity5.4 pink color is coming. But in texture i have my textures and all the details.
    How do i solve this issue?
    I cannot reexport all my assetbundle again from Unity5.4

  9. Glaswyll

    Sep 05, 2016 02:13

    This is not resolved. Still exists in 5.4.0f3

  10. maiacordero

    Aug 19, 2016 21:15

    Hi, this issue still happen in Unity 5.4.0f3 the last version.
    I'm using this BuildPipeline.BuildAssetBundles(pathTemp, BuildAssetBundleOptions.None, BuildTarget.StandaloneOSXUniversal);

    When I use the bundler I have lost shader references than be see in the typical pink color.

    And I have to make a "hack" :

    //************ HACK ! still unfixed >.<' https://issuetracker.unity3d.com/issues/materials-lose-reference-to-textures-if-loaded-from-asset-bundles?page=2#comments
    Renderer[] renderers = imagesToLoad[i].GetComponentsInChildren<Renderer>();
    Material[] materials;
    string[] shaders;

    foreach (var rend in renderers)
    {
    materials = rend.sharedMaterials;
    shaders = new string[materials.Length];

    for (int i2 = 0; i2 < materials.Length; i2++)
    {
    shaders[i2] = materials[i2].shader.name;
    }

    for (int i2 = 0; i2 < materials.Length; i2++)
    {
    materials[i2].shader = Shader.Find(shaders[i2]);
    }
    }

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.