SetColor for UIText object

using UnityEngine;
using System.Collections;

public class Visiblity : MonoBehaviour
{
    public GUIText Text;
    void OnTriggerStay2D (Collider2D other)
    {

        if (other.gameObject.tag == "Player")
        {
            Text.material.SetColor( Color.black);
        }
    }
}

How do I use the SetColor argument(I think it’s an argument) to change the color? I get this error:
error CS1501: No overload for method SetColor' takes 1’ arguments
Thanks in advance.

Check out the documentation. That function needs to know which color field you would like to editor on the material. So, for the main color, you can use “_Color”.

Text.material.SetColor( "_Color", Color.black);

Or set the color directly using the color property

Text.material.color = Color.black;

Thanks so much guys! You’re really helpful. Good to know there are nice people here.

1 Like