- Home /
Different prefabs with same mesh but different textures(materials).
I think I am missing something here. I drop a .blend file and two PNG images into an Asset folder.
I create a game object with mesh filter and renderer pointed to PNG texture #1. I turn it into a prefab and it looks good.
Then I create a new game object but this time attempt to choose PNG texture #2 on the mesh renderer.
This changes the first prefab to texture #2 as well.
Someone please point out what I am doing wrong here, as these are two different Mesh Renderers and should not be linked at all.
Unity 2.6.1
Thanks
Answer by Gabriel 1 · Oct 06, 2010 at 04:58 AM
Materials are NOT textures. Texturing a model is a 3 step process:
Texture --> Material --> Model
This means you take a texture and use it in a Material. The Material defines not just the Texture(s) in use, but also the Shader, color, effects, UV offsets, etc applied to the model.
What you're doing is using the same material on two different objects. When you change the texture in that Material, it of course affects both models since they both use the same Material.
To fix, you need to create a new material. The easiest way is to duplicate the current one. Select the Material you want to duplicate in the Hierarchy window. Go up to the EDIT menu and click DUPLICATE. You'll now have a new Material. Rename that material and select your second texture for this material. Last step is to go to you model and select the new material instead of the old one. You'll find the Material selection in the MESH RENDERER component of your model.
Thanks for the explanation. I understand that textures are not materials but was confused that 2 different prefabs were sharing the same material, I thought it was duplicated when i duplicated the game object.
Thanks again for your help.