This bugs me so much because I know it should work but it doesn’t. I have this code:
public class TMP_FadeIn : MonoBehaviour
{
public float duration = 0.5f;
[HideInInspector]
public bool onStart = false;
[HideInInspector]
public float end = 0f;
private TMP_Text text;
private void Start()
{
text = gameObject.GetComponent<TMP_Text>();
if (onStart)
{
text.color = new Color(text.color.r, text.color.g, text.color.b, 0f);
StartCoroutine(FadeInEnum(end, duration));
}
}
public void FadeIn(float end, float duration) => StartCoroutine(FadeInEnum(end, duration));
public IEnumerator FadeInEnum(float end, float duration)
{
float currentTime = 0f;
while (currentTime < duration)
{
float alpha = Mathf.Lerp(0f, end / 255f, currentTime / duration);
text.color = new Color(text.color.r, text.color.g, text.color.b, alpha);
currentTime += Time.deltaTime;
yield return null;
}
yield break;
}
}
And regardless of what method I use, I cannot find it in the inspector even though they’re public: