Change pixel color of Material from URL

Hello everybody, I’m in the process of learning Unity3D and I’m a bit stuck on something. I have a an object with a PNG material that is pulled from a url. To do this I used the C# code here: http://docs.unity3d.com/Documentation/ScriptReference/WWW.html and it works just fine.

Now what I’d like to do is change the black pixels in the PNG image I’m grabbing to be transparent. I think I need get/set pixels to do this, and the image is coming from NASA, so it should be safe, but I’m having trouble because (for example) the setpixels code on Unity’s site is only in javascript…

Any help would be greatly appreciated. Thank you!

Translating UnityScript to C# is really quite easy. You should try it yourself next time you encounter one of those pages in the Unity docs that are only in US. For instance, the code on the [Texture2D.SetPixels][1] page, translated to C# looks like this:

void Start ()
{
    Texture2D texture = Instantiate(renderer.material.mainTexture);
    renderer.material.mainTexture = texture;
    Color[] colors = new Color[3];
    colors[0] = Color.red;
    colors[1] = Color.green;
    colors[2] = Color.blue;
    int mipCount = Mathf.Min( 3, texture.mipmapCount );
    for(int mip = 0; mip < mipCount; ++mip)
    {
        Color[] cols = texture.GetPixels(mip);
        for(int i = 0; i < cols.Length; ++i)
        {
            cols _= Color.Lerp(cols*, colors[mip], 0.33 );*_

}
texture.SetPixels( cols, mip );
}
texture.Apply( false );
}
_*[1]: http://docs.unity3d.com/Documentation/ScriptReference/Texture2D.SetPixels.html*_