Hello everyone, i want to make fading text like Mr jump (Tap to Play Text). But i did not. It is like this video:
Please can you help me?
Hello everyone, i want to make fading text like Mr jump (Tap to Play Text). But i did not. It is like this video:
Please can you help me?
Are you using the new UI system, with a Canvas?
If so, attach a CanvasGroup component to the Canvas that is a parent of all the graphics that make up your text (button, Text, bg image, etc). CanvasGroup as an âalphaâ value on it.
Then in a script, set a public variable for the CanvasGroup. And in it, during Update, ping pong a value from 0-1 at a speed. And set the alpha value with that.
Like this:
public class PingPongCanvasGroupAlpha : MonoBehaviour
{
public CanvasGroup target;
public float speed = 1f;
private float _t = 0f;
void Update()
{
_t += Time.deltaTime * speed;
target.alpha = Mathf.PingPong(_t, 1f);
}
}
hi, if you do a search for âunity animate text alphaâ youâll find many examples, but most likely you have to customize those for your needs.
Also, if you want to keep it simple; add animator, and canvas group to your object (for example) and then animate alpha value.
EDIT: oops - didnât refresh page. Was late.
Thank you so much. It is working ![]()
If you want to finetune the effect, you can also swap Mathf.PingPong from @lordofduct 's example to sine.
This way you get a non-linear wave like animation (my eye says that is the case with your example, it doesnât have a âsharpâ feel near its endâŚ). Just try this with the code you have:
Mathf.Sin(Time.time * speed) * 0.5f + 0.5f;
This will give you a smooth wave like alpha transition that stays between 0-1.