Flash Fading Text

I need help. I want to make it in my game so I can fade my text in when you do something, almost like a warning. But I can’t do it. I have this function that is supposed to do it, but it both of the functions don’t do anything.

Here is the code.

public void flashMessage(TMP_Text message)
    {
        message.alpha = message.alpha + (fadeSpeed * Time.deltaTime);
        
        message.CrossFadeAlpha(0.5f, 1f, false);
    }

When the function is called, I know it is, (I have a debug.log) but nothing happens to the text.

2 Answers

2

Hello @calebaleb,

The unity doc says “CrossFadeAlpha: Creates a fading effect on a Graphic with a CanvasRenderer attached”

Also in the same documentation there is an example of something similar to what you want to achieve.
Remember to read the doc when a function doesn’t work as intended :slight_smile:

I hope it helps

I found the problem. I was calling the function inside a custom void function which wasn’t the right place. Thanks for the help though!