So, im trying to (upon buttonpush) show a crosshair Guitexture, and the upon button release, the alpha of that texture should fade out. However this doesnt happen, and Im still kind of new with C#(Ive done this before in JS, but C# is tricky with this, it seems)
I cant make sense of the other posts on this subject, for my particular case. Anyways, here is the code as it looks now:
Reticle is my GuiTexture
if(Input.GetKey(KeyCode.F))
{
reticle.color = new Color(0.5f,0.5f,0.5f,0.2f);
}
if (!Input.GetKey(KeyCode.F))
{
StartCoroutine("FadeAlpha");
}
IEnumerator FadeAlpha(){
reticle.color =new Color(0.5f,0.5f,0.5f,( Mathf.Lerp(0.2f,0.0f,0.6f)));
yield return 0;
}
This results in the alpha jumping to a lower value (20, in the inspector) and so the GuiTexture is still slightly visible. Also, it does not Lerp at all, which is probably something about Coroutines im doing wrong. Sorry to post another subject on this…