I want to update my score with animation like 2048. In this link (2048) you can play and see +4, +8 animated text while updating score.
there you go - I made a complete scene using a different approach than your
Draw the “+Number” text over your score and move it up each frame. Reduce the alpha value each frame as well and it will have a fading effect just like that. Remove or reset it once it becomes invisible.
I made it. Codes are belowed.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class AnimateText : MonoBehaviour
{
public Text txt;
public float moveSpeed = 100.0f;
public float alphaValue = 1.0f;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (alphaValue <= 0.0f) {
txt.transform.Translate (new Vector2 (0, 0));
txt.enabled = false;
} else {
txt.transform.Translate (new Vector2 (0, moveSpeed) * Time.deltaTime);
alphaValue -= Time.deltaTime;
txt.color = new Color (1.0f, 1.0f, 1.0f, alphaValue);
}
}
public void Exit ()
{
Application.Quit ();
}
public void Restart(){
Application.LoadLevel (0);
}
}