Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mbourland · Apr 10, 2012 at 08:36 PM · materialassetbundle

Problem with materials after creating Asset Bundle

I have a script that creates asset bundles. I pulled it from http://unity3d.com/support/documentation/ScriptReference/BuildPipeline.BuildAssetBundle.html?from=AssetBundle and used it in its entirety.

When I load the asset bundle at runtime and instantiate a prefab via GameObject.Instantiate(), the material associated with the prefab has all of the transparent areas replaced with yellow and the rest of the material is a pseudo-negative image. However, the textures are loaded just fine. It's only the materials that are affected.

I am using the EZGUI and SpriteManager2 plugins. This may or may not be a factor. Before including these prefabs in the asset bundle, they worked perfectly. What could be causing the yellow negatives in the materials?

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image rutter · Apr 10, 2012 at 08:53 PM 0
Share

I haven't seen that particular problem, but you might be right to suspect those plugins. It may be helpful to try and reproduce the problem using the simplest setup possible -- won't necessarily solve the problem, but could help narrow it down.

avatar image mbourland · Apr 11, 2012 at 11:47 PM 0
Share

We figured out that any texture that is imported as a non-compressed texture such as Automatic True Color or Automatic 16-bit, when it is attached to a material on a prefab that is included in the asset bundle, it comes out looking as described above. The transparency areas are all yellow and the rest of the image is a negative image.

Is there any way we can use non-compressed textures attached to materials, attached to prefabs in an asset bundle?

avatar image mbourland · Apr 12, 2012 at 12:13 AM 0
Share

Also, FYI, our asset bundles are targeting iPhonePlayer.

avatar image Evil-Dog · Apr 25, 2012 at 06:21 AM 0
Share

Any update to this? I also have similar issues but in my case the loaded texture from an asset bundle is purple-ish and semi transparent.

avatar image mbourland · Apr 27, 2012 at 02:52 PM 0
Share

No new updates. We have since moved away from the asset bundles, because of that issue.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by ncoder · May 29, 2012 at 10:57 PM

This might or might not help you:

We do this after loading a bundle:

     var materials = bundleEntry.bundle.LoadAll(typeof(Material));

     foreach(Material m in materials)
     {
         var shaderName = m.shader.name;
         var newShader = Shader.Find(shaderName);
         if(newShader != null)
         {
             m.shader = newShader;
         }
         else
         {
             Debug.LogWarning("unable to refresh shader: "+ shaderName + " in material " + m.name);
         }
     }

We also make sure that all our shaders are under a "Resources" folder, so that they are available at runtime regardless of usage.

This seems to be required only on Windows and iOS (possibly other platforms), but not on MacOS. There was some speculation that this is because shaders are considered "code", and not included in the bundle.

Note: This method is not perfect, since modifying assets in an asset bundles causes other errors. I'm investigating a good fix to this last one right now. It might work fine for your uses, though.

Asset bundles have many undocumented gotchas. good luck.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unitylepi · Mar 25, 2020 at 05:51 PM 1
Share

works well for most shaders, but those with rendermode set to transparent or fade suddenly get a different z-buffering behaviour ;(

avatar image
1

Answer by Evil-Dog · Apr 30, 2012 at 01:30 PM

I was having a somewhat similar problem that you have seen in my comment, maybe this "solution" is not related at all to your problem but here it is. My issue was simply that I was using assetbundles of the wrong type. Basically I was targeting Android but when testing on PC, textures from the android bundles would show up as corrupted, in my case, purplish and semi transparent. But on the android device it was fine. To see the stuff well on PC, I needed to make PC asset bundles. That's determined by the target you pass as parameter in BuildPipeline.BuildAssetBundles. So not a real issue, just a misunderstanding of the asset bundles on my part. Hopefully, your problem was the same thing.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unitylepi · Mar 26, 2020 at 05:45 PM 1
Share

No I'm strictly building for pc in both cases (bundles and main game) and my problem was solved by refreshing the shaders, however, this fix actually breaks transparent shaders that were working before the fix. $$anonymous$$y intermediate fix is to include some data in the assetbundle telling the main game exactly which materials to refresh and which to leave alone :(

avatar image IsabelleT unitylepi · May 07, 2020 at 09:37 AM 0
Share

I have the same problem with the unity 2019.3.12f. What is exactly your intermediate fix ?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to use same material? 0 Answers

Why/how is the material messed up on this cube after scene switch? 0 Answers

Material load from asset bundle are missing texture 1 Answer

Shader/Material not displaying properly when attached model loaded from bundle 0 Answers

Unity Addressable : Load multiple catalog problem 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges