Get single component from canvas, instead of all components

I’m a newbie in Unity (though I have experience in C#), so I’m following some tutorials and making a few modifications to learn more.

I have this script, that makes a Text component fade away:

public class FadeAway : MonoBehaviour {

    [SerializeField] private Text _textUI;

    private CountdownTimer countdownTimer;
    private int fadeDuration = 5;
    private bool fading = false;

	// Use this for initialization
	void Start () {
        countdownTimer = GetComponent<CountdownTimer>();
        StartFading(fadeDuration);
	}
	
	// Update is called once per frame
	void Update () {
        if (fading){
            float alphaRemaining = countdownTimer.GetProportionTimeRemaining();
            print(alphaRemaining);
            Color color = _textUI.material.color;
            color.a = alphaRemaining;
            _textUI.material.color = color;

            if (alphaRemaining < 0.01)
                fading = false;
        }
	}

    private void StartFading(int timerTotal){
        countdownTimer.ResetTimer(timerTotal);
        fading = true;
    }
}

And also, this class that was given by the tutorial (I haven’t modded it) to act as a countdown timer:

public class CountdownTimer : MonoBehaviour 
{
	private float countdownTimerStartTime;
	private int countdownTimerDuration;

	public int GetTotalSeconds(){
		return countdownTimerDuration;
	}

	public void ResetTimer(int seconds){
		countdownTimerStartTime = Time.time;
		countdownTimerDuration = seconds;
	}

	public int GetSecondsRemaining(){
		int elapsedSeconds = (int)(Time.time - countdownTimerStartTime);
		int secondsLeft = (countdownTimerDuration - elapsedSeconds);
		return secondsLeft;
	}
	
	public float GetFractionSecondsRemaining(){
		float elapsedSeconds = (Time.time - countdownTimerStartTime);
		float secondsLeft = (countdownTimerDuration - elapsedSeconds);
		return secondsLeft;
	}
	
	public float GetProportionTimeRemaining(){
		float proportionLeft = (float)GetFractionSecondsRemaining() / (float)GetTotalSeconds();
		return proportionLeft;
	}
}

Anyway, the problem is: I used [SerializeField] to get the reference to a single component on my canvas, the UI.Text I want the script to be applied to. On the Inspector, I assigned both scripts above to this UI.Text and passed the same UI.Text as a reference to the FadeAway script. But, if I add any other UI.Text on my canvas, it fades away too, even though I explicitly passed the single component I wanted to modify as a parameter to my script. What is happening? Could it be something I forgot? Hope this isn’t a stupid question.

Good day.

I don’t see where you define the _textUI variable. I see you declare it, but, where define what object in the scene is?

If you are recieving the same effect on 2 texts is because you are not definig correctly what text you want to fade out, is probably you have something like “find child objects with Text component” to define it, so it finds 2 of them.

If want to have only 1 fade out, you need to define specificly what text is. for example, using transform.Find or making the variable public and assign it via scene inspector.

Bye!