在Unity使文字变色
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ShipIntro : MonoBehaviour {
public Image Arrow;
public Image IntroBack;
public Text txt;
protected bool isstart=false;
[Header("文本组")]
public string mColorFrontText = "<color=#00FF00>";
public string mColorBackText = "</color>";
// Use this for initialization
void Start () {
StartCoroutine (PlayImage(Arrow,1/30f));
StartCoroutine (PlayImage(IntroBack,1/30f));
StartCoroutine (PlayWords(txt,3.0f,false));
}
// Update is called once per frame
void Update () {
}
IEnumerator PlayImage(Image img,float time)
{
while (img.fillAmount < 1) {
img.fillAmount += Time.deltaTime;
yield return new WaitForSeconds (time);
if (img.fillAmount >= 1) {
isstart = true;
Debug.Log ("111");
}
}
}
IEnumerator PlayWords(Text txt,float time,bool isstart)
{
yield return new WaitForSeconds (2.0f);
string sout = string.Empty;
string s = "要变色的文字。";
for (int i = 0; i <= s.Length; i++) {
sout = s.Substring (0,i);
txt.text = sout;
yield return new WaitForSeconds (time/s.Length);
}
if (!isstart) {
Debug.Log ("22");
yield return new WaitForSeconds (3.0f);
for(int i=0;i<s.Length;i++)
{
sout=mColorFrontText+s.Insert(i,mColorBackText);
txt.text=sout;
yield return new WaitForSeconds(time/s.Length);
}
}
}
}
在Unity使文字变色的更多相关文章
- 安卓中 使用html来使文字变色Html.fromHtml
在这里 我是用的html使文字的个别颜色变红 String textStr = " 本课程为<font color=\"#FF0000\">" + ...
- Unity使Text 文字逐个出现
Text tex; string s="Unity使Text 文字逐个出现"; //字符出现间隔 waitTime = 0.3f; // float speed=0; //方法一 ...
- Android TextView 中实现部分文字变色以及点击事件
首先要想实现文字变色以及点击,都需要使用到SpannableStringBuilder,实例化该类也很简单,只需将你想要处理的字符串当做参数 SpannableStringBuilder spanna ...
- Unity NGUI UILabel文字变色 及相关问题
在同一个UILabel中可以有不同颜色的文字只需要添加BBCode标记[ff0000]Red Label[-],那么在这个标记之间的RedLabel 就会变成红色 注意: 1.文本最终显示的颜色=Co ...
- iOS-NSAttributedString自定义文字变色
1.使用注意: 1.给UILabel设置attributedText了会导致给UILabel中text,font,textColor,shadowColor,shadowOffset,textAlig ...
- Android学习 之 ColorStateList按钮文字变色
首先添加一个ColorStateList资源XML文件,XML文件保存在res/color/button_text.xml: <?xml version="1.0" enco ...
- 转 Android学习 之 ColorStateList按钮文字变色
Windows平台VC,对于不同的按钮状态,采用不同的颜色显示文字,实现起来比较复杂,一般都得自绘按钮.但是Android里面实现起来非常方便. 我们首先添加一个ColorStateList资源XML ...
- line-height属性使文字垂直居中原理
原理:line-height与font-size的计算之差(在CSS中成为“行间距”)分为两半,分别加到一个文本内容的顶部和底部,这样就使得文字垂直居中了.
- 使文字在div中水平和垂直居中的的css样式为,四个边分别设置阴影样式
text-align:center; /*水平居中*/ line-height: 20px; /*行距设为与div高度一致*/ HTML元素 <div>水平垂直居中</div> ...
随机推荐
- 阿里云Ubuntu安装图形界面与中文语言包
图形界面: http://blog.csdn.net/qq_37608398/article/details/78155568?locationNum=9&fps=1 安装中文: http:/ ...
- ELK 经典用法—企业自定义日志收集切割和mysql模块
本文收录在Linux运维企业架构实战系列 一.收集切割公司自定义的日志 很多公司的日志并不是和服务默认的日志格式一致,因此,就需要我们来进行切割了. 1.需切割的日志示例 2018-02-24 11: ...
- JVM(二)Java虚拟机组成详解
导读:详细而深入的总结,是对知识"豁然开朗"之后的"刻骨铭心",想忘记都难. Java虚拟机(Java Virtual Machine)下文简称jvm,上一篇我 ...
- JaveWeb学习之Servlet(二):ServletConfig和ServletContext
原文同步发表至个人博客[夜月归途] 原文链接:http://www.guitu18.com/se/java/2018-07-26/20.html 作者:夜月归途 出处:http://www.guitu ...
- c语言之gdb调试。
1.此文档演示如何使用gdb调试c语言代码. 代码如下: #include <stdio.h> /*函数声明*/ void digui(int n); int main() { ; dig ...
- Ajax请求中的async:false/true(同步/异步)的作用
async. 默认是true,即为异步方式,$.Ajax执行后,会继续执行ajax后面的脚本,直到服务器端返回数据后,触发$.Ajax里的success方法,这时候执行的是两个线程.若要将其设置为fa ...
- js 递归修改json无限级key值
var tree = [ { name: 'node1' }, { name: 'node2', children: [{ name: 'node-2-1' }, { name: 'node2-2' ...
- max-width和width的区别
width为宽度 max-width为最大宽度 如果设置了width,那宽度就定死了,不能动态的改变,显得僵硬 而设置了max-width,实际宽度可以在0~max-width之间,当元素内部宽度不足 ...
- Dynamics CRM教程:图表的Top设置及导出修改和导入
关注本人微信和易信公众号: 微软动态CRM专家罗勇,回复144或者20150412可方便获取本文,同时可以在第一时间得到我发布的最新的博文信息,follow me! 上一篇博客制作的图表放在Dashb ...
- 为什么我觉得Python烂的要死?
为什么我觉得Python烂的要死? https://www.toutiao.com/a6636558446030225923/ 作为机器学习程序员的首选编程语言,Python成为世界范围内最受大学生欢 ...