- Home /
Texture change problem
Hi!
I am working on a card-game for PC. I am new to most of javascript, and I have a problem with Textures. I have a texture-array, and I read card info from a file. So far so good.
I want to instantiate several cards from my prefab, and have several different faces on the cards. The prefab has 3 materials. One for back, one for side and one for face. I want the faces to be different on each card. But when I instantiate a new card with a face different than the previous card, the faces on all cards change instead of only the new one.
So when 1 card is loaded, it has its own face texture. When the second card is loaded, both of them have the second card's texture. How do I change the texture of only ONE instance of a prefab?
I get the feeling that I should change the material rather than the texture, so I also tried to create a new material from code, but when I try to apply it to the object, nothing happens;
var NewFront = new Material (Shader.Find ("Diffuse"));
NewFront.SetTexture("_MainTex", GameObject.Find("TextureStore").GetComponent("Textures").Index[pic]);
CardObject.renderer.materials[2] = NewFront;
I have been struggling with this for hours, so I am thankful for help!
Your answer
Follow this Question
Related Questions
Blending one material/texture/shader to another 1 Answer
Food bar help 1 Answer
reference Gui texture outside script 1 Answer
How can i dynamically change texture 1 Answer
dirty lens effect over light help 1 Answer