- Home /
Unity5.0 material not assigned on android
I dynamically assign a gameobject's texture to randomly generate different cars with the same texture. Here's how I do it within my script (C#):
car.GetComponentInChildren<MeshRenderer>().GetComponent<Renderer>().material.mainTexture = mTexture;
This code worked in unity 4.4, but when I updated to unity 5.0 it stopped working. It also works in the editor, but just not when I build onto my android phone. Instead I get the pink missing texture color thing.
Is there another way to accomplish what I want to do? or is there a fix to the way I am doing it?
Comment
Best Answer
Answer by kschieck · Mar 10, 2015 at 05:27 PM
Turns out it was because I was setting the texture when I should have been setting the material. I created a material with a legacy shader (for now) that contains a mainTexture attribute and set that.