Changing the opacity of a transparent texture
<p>I have a transparent texture of a chain link fence. I want the fence to fade in as the player approaches from the z direction. The problem I am having is that because the fence is transparent the opacity slider disappears and uses the image transparency. (I want the transparent texture to fade in) My current code:</p>

<pre><code>public class WallFader : MonoBehaviour {


public GameObject wallone;

private Vector3 wallonetransform;

private Color wallonecolor;


public GameObject player;
private Vector3 playerposition;

private float PPX;
private float PPZ;

// Use this for initialization
void Start()

{
    wallonetransform = wallone.GetComponent&lt;Transform&gt;().position;
    wallonecolor = wallone.GetComponent&lt;Renderer&gt;().material.color;

}

// Update is called once per frame
void Update () {


    playerposition = player.transform.position;
    PPX = playerposition.x;
    PPZ = playerposition.z;

    // Distance to the large flat wall
    float wallonedist = wallonetransform.z - PPZ;

    if (wallonedist &gt; 10)
    {
        wallonecolor.a = 0;
    }

    else
    {
        //fade in script
    }

  }
</code></pre>

<p>The fence never fades or disappears when wallonedist is > 10</p>