Question by 
               Mokenister · Feb 21, 2016 at 02:28 AM · 
                texturematerialrenderer  
              
 
              Can someone change this array to use materials instead of textures
So I found this code on youtube but I want to swap materials instead of textures, even though It's the same I already have a bunch of materials prepared. public Texture[] textures; public int currentTexture;
 void Update ()
 {
     if (Input.GetKeyDown(KeyCode.C))
     {
         currentTexture++;
         currentTexture %= textures.Length;
         GetComponent<Renderer>().material.mainTexture = textures[currentTexture];
     }
 }
 
               Note that changing "public Texture[] textures;" into "public Material[] textures;" doesn't work
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Cherno · Feb 21, 2016 at 02:53 AM
 public Material[] textures; 
 public int currentTexture;
 
  void Update ()
  {
      if (Input.GetKeyDown(KeyCode.C))
      {
          currentTexture++;
          currentTexture %= textures.Length;
          GetComponent<Renderer>().material= textures[currentTexture];
      }
  }
 
              Your answer
 
             Follow this Question
Related Questions
How to load material onto sphere? 1 Answer
Material disappears after LoadScene 1 Answer
Render Pipeline Material Issue 1 Answer
Material to texture 0 Answers
Tree leaves underside not showing 0 Answers