Hi, I’d link to have a single mesh model with 3dsmax (a face with eyes) with more texture applied to it, one for eyes, one for face. I have exported as fbx and it works. Now I’d like to change the texture of the eye dynamically. I added in 3dsmax the texture and export to unity, I can see the 3 textures BUT I don’t know how to replace the texture of the eye with the other texture…
You can either replace the material on the model, or replace the texture in the material.
If you replace the texture in the material, this will affect all objects which use that material. (Unless you clone the material, which is doable, but can cause memory issues if you’re not careful.)
So it’s probably better to just replace the material on your object. Create a material for each eye texture. Then figure out which material on your MeshRenderer is the one you want to change — let’s suppose it’s number 1 (I can’t really tell from your screen shot, but let’s just suppose). Then in code, you could do something like
MeshRenderer mr = GetComponent<MeshRenderer>;
Material[] mats = mr.sharedMaterials;
mats[1] = newEyeMaterial;
mr.sharedMaterials = mats;
ok thanks, works great!
1 Like