Changing opacity of a GUITexture element

Hi,

I'm very new to Unity, and am looking to 'pulse' (fade in & out repeatedly) a GUITexture or GUIText element.

Can anybody give me any pointers on how I might achieve this? Searched for answers here but couldn't find much.

Cheers

You want to change the Alpha of the Color.

http://unity3d.com/support/documentation/ScriptReference/Color-a.html

Using a sin wave the code would be something like this in c#:

void OnGUI()
{
    Color textureColor = guiTexture.color;
    textureColor.a = Mathf.Sin(Time.time * 5.0f);
    guiTexture.color = textureColor;
}

Just make the 5.0f higher for a faster rate.

You should look into iTween. It's a very nice tweening library for Unity and you could use it for fading. There is even built in function for this. I'm linking to an answer I gave earlier. You can find it here

You could use interpolation.

Ex.

// Converts a white color to a black one trough time. var lerpedColor : Color = Color.white; function Update() { lerpedColor = Color.Lerp(Color.white, Color.black, Time.time); }

Take this idea now merge it with a guiTexture.color

function Update() { guiTexture.color = Color.Lerp(guiTexture.color, Color.red, Time.time); }

Another idea would be to use something like a sine wave. Might be even better option, since it would be infinite.