在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> ...
随机推荐
- linux添加C#运行环境
linux是不带C#的运行环境的,同样的还有.NET. 有一个叫做Mono的很好用http://www.go-mono.com/,有给docker,而且有环境的选择,要注意. 安好后有给样例的程序,编 ...
- 微信公众号通过图片选取接口上传到阿里oss
前言 之前写过一篇微信JS-SDK的使用方法,可进行参考 https://www.cnblogs.com/fozero/p/10256862.html 配置并调用公众号接口权限 1.配置权限微信公众号 ...
- 解析JavaScrip之对象属性
对于面向对象编程语言(如java,.net,php,python等)来说,其最大的特点在于“面向对象”,而"面向对象"较为显著的特征便是:封装,继承,多态.借助”面向对象“的这些特 ...
- python基础6--面向对象基础、装饰器
1.类 class Student: def __init__(self, name, grade): self.name = name self.grade = grade def introduc ...
- Using rqt_console and roslaunch
Description: This tutorial introduces ROS using rqt_console and rqt_logger_level for debugging and r ...
- mac IntelliJ Idea添加schema和dtd约束提示
打开设置 找到Schemac and DTDs 配置约束文件
- 2019-02-20 在PyPI测试平台发布Python包
参考Packaging Python Projects, 源码在nobodxbodon/test-package-for-pypi 包名/__init__.py: 测试变量 = "值&quo ...
- ios手机录屏软件哪个好
苹果手机中的airplay镜像,是苹果手机系统的一大特色,可以轻松把手机屏幕投射电脑,这个功能使苹果手机相较安卓手机投屏会更加轻松,那么如何实现苹果手机投射电脑屏幕?下面小编便来分享ios手机录屏软件 ...
- JS的MD5加密
/* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as d ...
- ArcGIS for JavaScript学习(二)Server发布服务
一 ArcGIS for Server 安装.配置 (1)双击setup (2)点击下一步完成安装 (3)配置 a 登录Manager 开始—>程序—>ArcGIS—>Manager ...