I wrote a script to change the alpha of a Vertex Color shader. It works fine in the editor, but doesn't fade to transparent on the iPhone (3Gs). I'm not sure if this is a technical limitation of the phone, or if I don't understand what I am doing again. Thanks in advance.
using UnityEngine;
using System.Collections;
public class FadeAway : MonoBehaviour {
public float targetAlphaValue = 0.0f; // target alpha value 0.0f to 1.0f
public float fadeTime = 1.75f; // time to fade to target alpha value
private Color startColor;
private Color targetColor;
private Color lerpedColor;
private Material objMaterial;
// Use this for initialization
void Start () {
objMaterial = gameObject.renderer.material;
startColor = objMaterial.color;
targetColor = new Color(startColor.r,startColor.g,startColor.b,targetAlphaValue);
}
// Update is called once per frame
void Update () {
lerpedColor = Color.Lerp(startColor, targetColor, fadeTime);
objMaterial.color = lerpedColor;
}
void ResetColor(){
objMaterial.color = startColor;
}
}