# Flash Fading Text

**URL:** <https://discussions.unity.com/t/flash-fading-text/354242>\
**Category:** Questions & Answers\
**Tags:** Scripting, Text, Question\
**Created:** [April 22, 2024, 11:10pm UTC](https://discussions.unity.com/t/flash-fading-text/354242 "2024-04-22T23:10:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![calebaleb](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/calebaleb/32/85437_2.png) [@calebaleb](https://discussions.unity.com/u/calebaleb)\
**Post date:** [April 22, 2024, 11:10pm UTC](https://discussions.unity.com/t/flash-fading-text/354242/1 "2024-04-22T23:10:07Z")

</div>

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.**

```auto
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.

---

<div class="post-metadata">

**Author:** ![Cyber\_Cats](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/cyber_cats/32/99539_2.png) [@Cyber\_Cats](https://discussions.unity.com/u/Cyber_Cats)\
**Post date:** [April 22, 2024, 11:32pm UTC](https://discussions.unity.com/t/flash-fading-text/354242/2 "2024-04-22T23:32:40Z")

</div>

Hello @calebaleb,

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

> **[Unity - Scripting API: UI.Graphic.CrossFadeAlpha](https://docs.unity3d.com/2018.1/Documentation/ScriptReference/UI.Graphic.CrossFadeAlpha.html)**

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 🙂

I hope it helps

---

<div class="post-metadata">

**Author:** ![calebaleb](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/calebaleb/32/85437_2.png) [@calebaleb](https://discussions.unity.com/u/calebaleb)\
**Post date:** [April 22, 2024, 11:56pm UTC](https://discussions.unity.com/t/flash-fading-text/354242/3 "2024-04-22T23:56:37Z")

</div>

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!
