Is there a way to subclass UnityEngine.UI.Text (or any game object or UI element for that matter) and add an instance of that to the scene? That way I can override the setter for text property and start fading it out (or do something else) when value changed.
What I’ve read here suggests attaching a script to the object and using SetActive to start fading:
To be honest there are a million ways of doing this. The easiest way I can think of is to attach a canvas group component and a second script that checks if Text value has changed. If it has, it starts a coroutine to set canvasGroup.alpha to zero over time. Or you can add an animator and an animation for the canvas group alpha and just set animator state when the value changes.
You can also do it as in the link you provided. Or you can subclass the UI.Text, or mix all of the above. There is no one proper way of doing this, it all depends on your code structure, scene hierarchy, your skills and whether you prefer doing things mostly in code or by utilizing the editor.
This will set your FadeText.text value and also call your StartFade function, I’m pretty sure Text inherits from monobehaviour so your FadeText will also, and therefore you should be able to begin a coroutine within the class!