- Home /
Im changing textures on my materials for all the objects in the game, but not all the changes happen on runtime.
So i have palette materials and unlit/texture materials. When i change their main texture with scripts, the palette materials change when the instruction is excecuted, but the unlit/texture materials change AFTER i reaload the scene. Also, when i reload the scene, the material original texture is no reset. Only if I close>open my game (android) the materials have again their original textures.
How can i get the texture changes immediatly on my unlit/texture material? 2.-How can i reset the material textures? One solution could be that i asign the textures back to their respective originals by code before reloading the scene.
I have an array of the materials from my assets and the texture i use with those too. I change everything when a flag turns on, the i do something like this:
if (pasaje >= 10 && modoVapor == false) {
modoVapor = true;
musicaVapor.time = 38f;
musicaVapor.Play ();
//texturas
if (frenos) {
materiales [0].SetTexture ("_MainTex", texturas[3]);
materiales [2].SetTexture ("_MainTex", texturas[9]);
} else {
materiales [0].SetTexture ("_MainTex", texturas[2]);
materiales [2].SetTexture ("_MainTex", texturas[8]);
}
//el resto
materiales [1].SetTexture ("_MainTex", texturas[5]);
materiales [3].SetTexture ("_MainTex", texturas[11]);
materiales[4].SetTexture ("_MainTex", texturas[13]);
materiales[5].SetTexture ("_MainTex", texturas[14]);
}
if(pasaje < 10 && modoVapor == true){
modoVapor = false;
musicaVapor.Stop ();
//texturas
if (frenos) {
materiales [0].SetTexture ("_MainTex", texturas[1]);
materiales [2].SetTexture ("_MainTex", texturas[7]);
} else {
materiales [0].SetTexture ("_MainTex", texturas[0]);
materiales [2].SetTexture ("_MainTex", texturas[6]);
}
//el resto
materiales [1].SetTexture ("_MainTex", texturas[10]);
materiales [3].SetTexture ("_MainTex", texturas[4]);
materiales[4].SetTexture ("_MainTex", texturas[12]);
materiales[5].SetTexture ("_MainTex", texturas[15]);
}
Your answer
Follow this Question
Related Questions
Import Blender models 2 Answers
Prevent texture to seem streched? 1 Answer
Enforcing Fixed/Forced Texture Sizes in Unity 0 Answers
Cycle through object materials on mouse click in C# 1 Answer