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
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Editor crashes on StoredGraphicsBuffer::GetGfxBufferID when VFX Graph property is modified during Play Mode and Application.targetFrameRate is used to limit FPS
- Crash on NVAPI_Thunk when changing Player resolution while HDR display is used and Direct3D12 is set as the graphics API
- Only one out of multiple cameras is shown in the Play Mode while HDR display is used and Direct3D12 is set as the graphics API
- The "Paste Component as New" option is incorrectly displayed as active despite the action being prohibited
- "TLS Allocator ALLOC_TEMP_TLS" errors are thrown when unsuccessfully importing an FBX file
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 =)
ADaurio
Oct 21, 2016 15:09
This has not been resolved in Unity 5.4.
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.
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!
bearxiong
Oct 10, 2016 13:12
This is not resolved. Still exists in 5.4.1f1
Anemor2000
Oct 03, 2016 18:55
This is not fixed in 5.4....
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. :-(
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
Glaswyll
Sep 05, 2016 02:13
This is not resolved. Still exists in 5.4.0f3
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]);
}
}