C#: If I found the gameobject in the scene, why do I get the "access to a non-static member" error

I just want to make a UI button that disables the text component (the button is child of the text), and thereby they both gonna disappear.

I have this attached to the OnClick cfomponent of the button:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class SelfDestroy : MonoBehaviour {
    public GameObject IntroText;
    public void PrintOnScreen()
    {
        IntroText = GameObject.FindGameObjectWithTag ("ToDestroy");
        GameObject.GetComponent(IntroText).enabled = false;
}
}

The IntroText is a Text, but I imagine that even texts are considered game objects, right?

Anyway, it’s a mystery to me why I get this error if I found the text.

Assets/Scripts/SelfDestroy.cs(10,28): error CS0120: An object reference is required to access non-static member `UnityEngine.GameObject.GetComponent(System.Type)’

Help?

change line 10 to

IntroText.GetComponent<Text>().enabled = false;

Many many thanks :slight_smile: