title: Unity Lerping between multiple matierals
body: <p>I have a need to lerp through 10 different materials attached to one of my game objects but for some reason, the code I have written doesn't work. I have spent the past hour trying to workout why and I'm pretty burnt out. </p>
  
  <p>Could someone with fresher eyes please take a look and see if I'm doing some stupid?</p>
  
  <pre><code>public class LerpMaterials : MonoBehaviour
  {
  
  public List&lt;Material&gt; materials = new List&lt;Material&gt;();
  
  public float lerpSpeed;
  
  int currentMaterialNo;
  Material currentMaterial;
  Material targetMaterial;
  bool lerpingMaterial;
  
  float lerp;
  
  
  void Start ()
  {
      if (materials.Count &lt; 2)    return;
  
      currentMaterialNo = 0;
      currentMaterial = materials[currentMaterialNo];
      targetMaterial = materials[currentMaterialNo+1]; 
  }
  
  
  
  void Update ()
  {
      if (materials.Count &lt; 2)    return;
  
      lerp += lerpSpeed;
  
      renderer.material.Lerp(currentMaterial, targetMaterial, lerp);
  
      if (lerp &gt;= 1)
          SwitchMaterial();
  
  }
  
  
  void SwitchMaterial()
  {
      if ( currentMaterialNo &gt;= (materials.Count - 1) )
          currentMaterialNo = 0;
      else
          currentMaterialNo++;
  
      currentMaterial = materials[currentMaterialNo];
      targetMaterial = materials[currentMaterialNo++];
  
      lerp = 0;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My list holds every single material and my mesh renderer also holds the required materials as well. But nothing happens other than an instance of the first material appearing in the material renderer. No other movement. </p>