- Home /
Simple C# array for changing textures
I'm trying to create a simple object with 10 different textures showing different stages of decay as the player shoots it.
I set the textures as public textures:
public Texture Phase1; (all the way to 10)
After every hit I change the texture:
renderer.material.mainTexture = Phase2;
I'm setting up public textures. I know I can do that as an array, but I'm not sure about syntax.
Same for changing the material after every hit. I know I can have a variable I increase by one after every hit. So if it's "x" then all I have to do after every increase is write something like:
renderer.material.mainTexture = Phase+x;
Though I know the syntax is all wrong and it doesn't work. :-/
Answer by Eric5h5 · Apr 08, 2012 at 04:31 PM
public Texture2D[] phases;
...
renderer.material.mainTexture = phases[1];
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Changing texture of pressed button in array 1 Answer
Texture2D to Texture3D 2 Answers
Textures from array variabels? 1 Answer