一、动画效果使用animator实现
二、动画效果可拓展可修改
三、文字效果可修改,也可替换为图片
四、解决问题:1、复杂的文字显示效果;2、方便拓展修改;3、多语言版本不需要大量美术工作;
五、实现方法如下:
1、制作预制体;

2、根据字体样式修改文字大小:

3、代码播放动画:
(1)、预制体导出自动的脚本

using TMPro;
using UnityEngine;
using UnityEngine.UI;/// <summary>
/// TextBeatCom控件(导出时更新)
/// </summary>
public partial class TextBeatCom : UIComponentBase
{public ScrollRect m_scroll;public Animator m_a;public Animator m_b;public Animator m_c;public Animator m_d;public Animator m_e;public Animator m_f;public Animator m_g;public Animator m_h;public Animator m_i;public Animator m_j;public Animator m_k;public Animator m_l;public Animator m_m;public Animator m_n;public Animator m_o;public Animator m_p;public Animator m_q;public Animator m_r;public Animator m_s;public Animator m_t;public Animator m_u;public Animator m_v;public Animator m_w;public Animator m_x;public Animator m_y;public Animator m_z;public Animator m_A;public Animator m_B;public Animator m_C;public Animator m_D;public Animator m_E;public Animator m_F;public Animator m_G;public Animator m_H;public Animator m_I;public Animator m_J;public Animator m_K;public Animator m_L;public Animator m_M;public Animator m_N;public Animator m_O;public Animator m_P;public Animator m_Q;public Animator m_R;public Animator m_S;public Animator m_T;public Animator m_U;public Animator m_V;public Animator m_W;public Animator m_X;public Animator m_Y;public Animator m_Z;private void Awake(){m_scroll = transform.FindInAllChild("scroll_n").GetComponent<ScrollRect>();m_a = transform.FindInAllChild("a_n").GetComponent<Animator>();m_b = transform.FindInAllChild("b_n").GetComponent<Animator>();m_c = transform.FindInAllChild("c_n").GetComponent<Animator>();m_d = transform.FindInAllChild("d_n").GetComponent<Animator>();m_e = transform.FindInAllChild("e_n").GetComponent<Animator>();m_f = transform.FindInAllChild("f_n").GetComponent<Animator>();m_g = transform.FindInAllChild("g_n").GetComponent<Animator>();m_h = transform.FindInAllChild("h_n").GetComponent<Animator>();m_i = transform.FindInAllChild("i_n").GetComponent<Animator>();m_j = transform.FindInAllChild("j_n").GetComponent<Animator>();m_k = transform.FindInAllChild("k_n").GetComponent<Animator>();m_l = transform.FindInAllChild("l_n").GetComponent<Animator>();m_m = transform.FindInAllChild("m_n").GetComponent<Animator>();m_n = transform.FindInAllChild("n_n").GetComponent<Animator>();m_o = transform.FindInAllChild("o_n").GetComponent<Animator>();m_p = transform.FindInAllChild("p_n").GetComponent<Animator>();m_q = transform.FindInAllChild("q_n").GetComponent<Animator>();m_r = transform.FindInAllChild("r_n").GetComponent<Animator>();m_s = transform.FindInAllChild("s_n").GetComponent<Animator>();m_t = transform.FindInAllChild("t_n").GetComponent<Animator>();m_u = transform.FindInAllChild("u_n").GetComponent<Animator>();m_v = transform.FindInAllChild("v_n").GetComponent<Animator>();m_w = transform.FindInAllChild("w_n").GetComponent<Animator>();m_x = transform.FindInAllChild("x_n").GetComponent<Animator>();m_y = transform.FindInAllChild("y_n").GetComponent<Animator>();m_z = transform.FindInAllChild("z_n").GetComponent<Animator>();m_A = transform.FindInAllChild("A_n").GetComponent<Animator>();m_B = transform.FindInAllChild("B_n").GetComponent<Animator>();m_C = transform.FindInAllChild("C_n").GetComponent<Animator>();m_D = transform.FindInAllChild("D_n").GetComponent<Animator>();m_E = transform.FindInAllChild("E_n").GetComponent<Animator>();m_F = transform.FindInAllChild("F_n").GetComponent<Animator>();m_G = transform.FindInAllChild("G_n").GetComponent<Animator>();m_H = transform.FindInAllChild("H_n").GetComponent<Animator>();m_I = transform.FindInAllChild("I_n").GetComponent<Animator>();m_J = transform.FindInAllChild("J_n").GetComponent<Animator>();m_K = transform.FindInAllChild("K_n").GetComponent<Animator>();m_L = transform.FindInAllChild("L_n").GetComponent<Animator>();m_M = transform.FindInAllChild("M_n").GetComponent<Animator>();m_N = transform.FindInAllChild("N_n").GetComponent<Animator>();m_O = transform.FindInAllChild("O_n").GetComponent<Animator>();m_P = transform.FindInAllChild("P_n").GetComponent<Animator>();m_Q = transform.FindInAllChild("Q_n").GetComponent<Animator>();m_R = transform.FindInAllChild("R_n").GetComponent<Animator>();m_S = transform.FindInAllChild("S_n").GetComponent<Animator>();m_T = transform.FindInAllChild("T_n").GetComponent<Animator>();m_U = transform.FindInAllChild("U_n").GetComponent<Animator>();m_V = transform.FindInAllChild("V_n").GetComponent<Animator>();m_W = transform.FindInAllChild("W_n").GetComponent<Animator>();m_X = transform.FindInAllChild("X_n").GetComponent<Animator>();m_Y = transform.FindInAllChild("Y_n").GetComponent<Animator>();m_Z = transform.FindInAllChild("Z_n").GetComponent<Animator>();}
}

(2)、预制体实现效果的代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public partial class TextBeatCom
{List<RectTransform> m_showList = new List<RectTransform>();List<Animator> m_aniList = new List<Animator>();string m_text = string.Empty;public void Init(string text){m_text = text;ResetContent();ShowText();}void ShowText(){CreateTextItem();StartCoroutine(PlayAnimation());}void CreateTextItem(){float last = 0, move = 0;int length = m_text.Length;for (int index = 0; index < length; index++){var tChar = $"{m_text[index]}_n";Debug.Log($"char = {tChar}");var child = m_scroll.content.Find(tChar);if (child != null){var obj = GameObject.Instantiate(child, m_scroll.content.transform);if (obj != null){//obj.SetActive(true);var rt = obj.GetComponent<RectTransform>();move += rt.rect.width / 2 + last / 2;rt.anchoredPosition = new Vector2(move, 0);last = rt.rect.width;m_showList.Add(rt);m_aniList.Add(obj.GetComponent<Animator>());}}else{move += 50;//空格}}if (m_showList.Count > 0) move += (int)m_showList[0].rect.width >> 1;move = (int)move >> 1;for (int index = 0; index < m_showList.Count; index++){var obj = m_showList[index];var pos = obj.anchoredPosition;pos.x -= move;obj.anchoredPosition = pos;}}IEnumerator PlayAnimation(){yield return PlayShow();PlayBeat();}IEnumerator PlayShow(){int playFinishNum = 0;for (int i = 0; i < m_aniList.Count; i++){var obj = m_aniList[i];obj.SetActive(true);obj.OnPlay("Show").OnComplete(() => { playFinishNum++; });yield return new WaitForSeconds(0.05f);}yield return new WaitUntil(() => playFinishNum >= m_aniList.Count);}public void PlayBeat(){for (int index = 0; index < m_aniList.Count; index++){var obj = m_aniList[index];obj.Play("Beat");}}public void OnClear(){for (int i = 0; i < m_showList.Count; i++){var tran = m_showList[i];m_showList.Remove(tran);i--;GameObject.Destroy(tran.gameObject);}m_showList.Clear();m_aniList.Clear();}void ResetContent(){for (int index = 0; index < m_scroll.content.childCount; index++){m_scroll.content.GetChild(index).SetActive(false);}}
}

六、可以使用其他动画插件

Unity 文字显示动画相关推荐

  1. Unity之文字提示动画

    推荐阅读: 我的CSDN 我的博客园 QQ群:704621321 在游戏中,玩家进行了某种操作,往往需要给玩家一种提示,以告诉玩家操作结果:成功或失败提示.用于提示的的方式可以是弹框,也可以是文字渐隐 ...

  2. [转]Unity之文字提示动画

    在游戏中,玩家进行了某种操作,往往需要给玩家一种提示,以告诉玩家操作结果:成功或失败提示.用于提示的的方式可以是弹框,也可以是文字渐隐.弹框就是显示一些信息,并带有确定/取消按钮等.文字渐隐就是显示文 ...

  3. Unity中的动画系统和Timeline——笔记

    前言: 最近开始跟着SIKI学院系统学习Unity,这篇文章就是Unity中的动画系统和Timeline的笔记 动画 动画的录制和动画曲线的编辑 以前我都是在动画中一步一步来做动画,从来不知道还有这个 ...

  4. unity Timeline控制动画的播放

    unity Timeline控制动画的播放 创建一个空物体GameObject,添加Playable Director组件,添加脚本组件: 新建一个长方体: 创建timeline并将其拖到空物体的Pl ...

  5. html语言鼠标悬停特效,CSS3鼠标悬停文字幻影动画特效

    这是一款CSS3鼠标悬停文字幻影动画特效.该特效利用before和after伪元素来制作当鼠标悬停在超链接文本上的时候的幻影效果. 使用方法 在页面中引入bootstrap.css.jquery和ph ...

  6. php生成动态笔画字体,怎么制作手写文字的动画效果视频 文字一笔一划写出来的动画效果制作...

    有到了令人高兴的周五,是的没错,明天又可以各种浪了!不过呢,今天还是要好好工作好好学习滴!那么今天就分享一个好玩的文字动画制作方法给大家.这是一种很简单的文字动画效果,看上去就像是文字是由某人的手一笔 ...

  7. Unity载入骨骼动画详解

    Spine Skeleton Animation(2D骨骼动画) 骨骼动画 首先我们来看到底什么是骨骼动画: 在早期的机器上,渲染本身已经占用了很多CPU资源,因此,对于渲染,往往采取的是一种空间换时 ...

  8. wpf 字体模糊_WPF:解决WPF文字显示不清晰初探

    可能WPF太耀眼了,大家都一直在讨论它的光芒,我也是其中的一员. 当发现它给软件界面设计带来的革命性变化时,说服同事,在新项目中使用了WPF这一新技术. 无奈,项目快结束时,头头验收时说字体模糊,不能 ...

  9. FCPX插件:弹性文字标题动画CineFlare ObjectAnimator

    为大家带来一款FCPX插件:弹性文字标题动画CineFlare ObjectAnimator,这款fcpx文字标题动画插件适用于Final Cut Pro  X和FxFactory上,你可以在视频中为 ...

最新文章

  1. SpringBoot的日志管理(输出级别,输出到文件)
  2. SCCM 2012系列之一 Operations Manager 关键概念
  3. c语言hash存储,C语言实现HashTable(一) 介绍
  4. 中石油在意大利加油站0.5分/升,会不会赔死啊?
  5. Openssl的证书格式转换
  6. C++ 中vector的嵌套使用
  7. dz后台html,discuz X1.5 论坛后台站长常用操作小结
  8. mysql结果集键值对_键值对集合DictionaryK,V根据索引提取数据
  9. mysql 自动生成mapper_Spring Boot整合mybatis并自动生成mapper和实体实例解析
  10. 在MySQL中使用正则表达式
  11. visio作图|入门教程+mathtype资源
  12. 稳压二极管的工作原理是什么?
  13. MQ--推模式与拉模式
  14. “汽车人”眼中的网络安全-网络安全的5W1H
  15. 保险与赌博的差异,航延险是赌博吗?
  16. 如何安装微信解决小黑块问题(一定可以使用)
  17. 如何判断自己IP是内网IP还是外网IP
  18. 中国驾照在美国各州开车的规定
  19. 自己封装的poi操作Excel工具类
  20. Python之浅谈exec函数

热门文章

  1. 现在小屁孩黑客太牛B了
  2. 基于机器视觉的多机械臂煤矸石分拣机器人系统研究
  3. 6.2 漫反射-半兰伯特
  4. 百度地图 地址查询经纬度 插件vue-baidu-map
  5. r语言remarkdown展示图_为什么Markdown R有较大概率成为科技写作主流? ← 阳志平的个人网站::技术...
  6. 计算机桌面屏幕怎么设置全屏,如何让电脑显示器屏幕显示全屏
  7. 机器学习 K近邻之KD树基本概念、绘制KD树
  8. 尾插法创建链表(C++代码)
  9. IBM第二季度营收超预期 向云服务转型战略初见成效
  10. 定义一个Tree(树)类,有成员ages(树龄),成员函数grow(int years)对ages加上years,age()显示tree对象的ages的值。