Set Opacity of text

How do I have a script set the opacity of the text?

using UnityEngine;
using System.Collections;

public class Visiblity : MonoBehaviour 
{
    
    public GameObject UIText;
       
        void OnTriggerStay2D (Collider2D other)
    {

        if (other.gameObject.tag == "Player")
        {
            Debug.Log ("Hi!");
        }
    }
}

I want to replace the Debug.Log to make the public gameobject variable called UIText with an opacity of 255. How do I LERP two UI Text colours? I don’t think that this is that hard to answer. Probably an easy solution. But, being a n00b, I don’t get it. Help! Thanks!

If you store a reference to the Text component then you can set the color property directly after using Color.Lerp. In your example you’re storing the GameObject which isn’t so useful on its own.

Ok,but how do I do that? Public Text.UI?

UnityEngine.UI.Text

You can also use the UnityEngine.UI namespace to save typing.