title: How to change texture of game object in Unity?
body: <p>I'm working on Unity for a School Project and I am using Kinect to recognize facial expressions. The "default" expression it shows is Neutral and it changes as I change facial expression to Happy or Suprised, etc. </p>
  
  <p>I created a game object called Face where I set the different textures (faces that the PC shows in response to my expression) and I wanted him to change  when I change my facial expression. But for some reason it is not working.</p>
  
  <p>I am using C# and first I set this:</p>
  
  <pre><code>public static Texture[] textures = new Texture[7];
  public Texture neutral, smiling, happy, angry, sad, kissing, surprised;
  public GameObject Face;
  public Renderer rend;
  </code></pre>
  
  <p>In the Start I have this:</p>
  
  <pre><code>    Face = GameObject.Find ("Face");
  
      textures[0] = neutral;
      textures[1] = smiling;
      textures[2] = happy;
      textures[3] = angry;
      textures[4] = sad;
      textures[5] = sad;
      textures[6] = surprised;
  </code></pre>
  
  <p>By the way, it didn't find Face so I put it there by the inspector and I did the same with the textures/faces. 
  Then in the Update I put this which is defined below:</p>
  
  <pre><code>    ClassifyAndApply(numbers);
  
  
  private void SaveAnimUnits()
      {
          numbers[0] = _animUnits.LipRaiser;
          numbers[1] = _animUnits.JawLowerer;
          numbers[2] = _animUnits.LipStretcher;
          numbers[3] = _animUnits.BrowLowerer;
          numbers[4] = _animUnits.LipCornerDepressor;
          numbers[5] = _animUnits.OuterBrowRaiser;
      }
  
      private void ClassifyAndApply(float[] units){
  
  //      Renderer rend = GetComponent&lt;Renderer&gt;();
  //      Face = GameObject.Find ("Face");
  
  
  
          if (units[2] &lt;= 0.264888){
              if (units[3] &lt;= 0.817408){
                  if (units[1] &lt;= 0.181886){
                      if (units[0] &lt;= -0.216908){
                          if (units[4] &lt;= 0.395523){
                              if (units[1] &lt;= 0.104226){ 
                                  Face. GetComponent&lt;Renderer&gt;().material.mainTexture = textures[3];
                              }
                              else{ 
                                  Face. GetComponent&lt;Renderer&gt;().material.mainTexture = textures[0];
                              }
  </code></pre>
  
  <p>This tree continues but I think my problem is this but I am not sure.</p>
  
  <pre><code>Face. GetComponent&lt;Renderer&gt;().material.mainTexture = textures[0];
  </code></pre>