[UGUI]Text文字效果
参考链接:
http://www.xuanyusong.com/archives/3471
https://www.cnblogs.com/lyh916/p/9162463.html
https://www.cnblogs.com/zsb517/p/6565446.html
0.Text的顶点分布
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; public class TestMesh : BaseMeshEffect { public override void ModifyMesh(VertexHelper vh)
{
List<UIVertex> vertexs = new List<UIVertex>();
vh.GetUIVertexStream(vertexs);
for (int i = ; i < vertexs.Count; i++)
{
Debug.LogWarning(vertexs[i].position);
} print(vertexs.Count);
print(vh.currentIndexCount);
print(vh.currentVertCount);
}
}

新建一个text,然后使内容保留至一个字,添加上面的脚本。可以发现,1个字有4个顶点,而顶点的排列如下图。1个字由2个三角形组成,绘制顺序为0-1-2和2-3-0,顺时针绘制。

1.渐变效果
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; [AddComponentMenu("UI/Effects/Gradient")]
public class Gradient : BaseMeshEffect
{
[SerializeField]
private Color32 topColor = Color.white;
[SerializeField]
private Color32 bottomColor = Color.black; public override void ModifyMesh(VertexHelper vh)
{
List<UIVertex> vertexs = new List<UIVertex>();
vh.GetUIVertexStream(vertexs);
for (int i = ; i < vertexs.Count;)
{
SetVertexColor(vertexs, i, topColor);
SetVertexColor(vertexs, i + , topColor);
SetVertexColor(vertexs, i + , bottomColor);
SetVertexColor(vertexs, i + , bottomColor);
SetVertexColor(vertexs, i + , bottomColor);
SetVertexColor(vertexs, i + , topColor);
i += ;
}
vh.Clear();
vh.AddUIVertexTriangleStream(vertexs);
} private void SetVertexColor(List<UIVertex> vertexs, int index, Color32 color)
{
UIVertex vertex = vertexs[index];
vertex.color = color;
vertexs[index] = vertex;
}
}

2.阴影效果
UGUI自带Shadow脚本,可以下载UGUI源码查看其实现。新建一个Text并添加Shadow组件,将effectDistance距离调大,如下图。其中白字是自身,黑字是阴影效果,可以看到,阴影效果就是将顶点复制一份,然后向某一方向移动位置。

3.描边效果
UGUI自带Outline脚本,Outline继承Shadow,换言之,其实现与Shadow类似。新建一个Text并添加Outline组件,将effectDistance距离调大,如下图。其中白字是自身,黑字是描边效果,可以看到,描边效果就是将顶点复制四份,然后向四个方向移动位置。

[UGUI]Text文字效果的更多相关文章
- UGUI 文字效果实现(Shadow\Gradient\Outline)
NGUI直接在UILabel组件中接入了Shadow.Gradient和outline选项,但在UGUI中是通过另外的组件单独提供,比如outline.shader等.这篇文章主要记录这几个文字效果实 ...
- Qt qml 模拟iphone slide to unlock 的聚光动画文字效果
模拟iphone slide to unlock 的聚光动画文字效果 /底层放淡文字 /前景放高亮文字+半透明遮罩 /动画移动遮罩 Author: surfsky.cnblogs.c ...
- as3.0:文字 效果
//文字描边效果var tf1 = _root.createTextField("tf1", _root.getNextHighestDepth(), 10, 10, 0, 0); ...
- CSS Gradient文字效果
你想创建的标题没有渲染和Photoshop每个标题吗?这里是一个简单的CSS技巧向您展示如何创建渐变文字效果,PNG图像(纯CSS,没有Javascript或Flash).你所需要的是一个空的< ...
- 移动端 iphone锁屏文字效果
简易的仿照iphone 效果 笔记备份 <!DOCTYPE HTML> <html> <head> <meta http-equiv="Conten ...
- CSS3动画:流彩文字效果+图片模糊效果+边框伸展效果实现
前言 首先第一步,先布局html代码如下: <div class="wrap"> <img src="images/1.jpg" class= ...
- CSS3下的渐变文字效果实现
如下,第一种方法已实践 一.方法一:借助mask-image属性 可以狠狠地点击这里:CSS3下的渐变文字效果方法一demo 如果您手头上的浏览器是Chrome或是Safari,则您可以在demo页面 ...
- css文字效果(文字剪贴蒙版,text-shodow的应用,文字排版等…)
.katex { display: inline-block; text-align: initial; } .katex { font-family: Consolas, Inconsolata, ...
- 实现textview竖排文字效果
文字效果
随机推荐
- C++用 _findfirst 和 _findnext 查找文件
一.这两个函数均在io.h里面. 二.首先了解一下一个文件结构体: struct _finddata_t { unsigned attrib; time_t tim ...
- hyperledge fabric里order-kafka过程分析
Broadcast主要接收Peer的数据并在Orderer里面生成一系列数据块,主要流程见下图: Broadcast过程分析:Peer(客户端)通过GRPC发起通信,与Orderer连接成功之后,便可 ...
- linux新手非常有用的20个命令
引用:http://www.oschina.net/translate/useful-linux-commands-for-newbies 1. ls命令 ls命令是列出目录内容(List Direc ...
- Python多版本共存virtualenv配置
virtualenv 前提是已经安装好了python.我的ubuntu是自带了python2.7和python3.6 安装vrtualenv sudo apt-get install python-v ...
- Windows 2003 下安装 SQL Server 2008 Express
.NET Framework 3.5 Service Pack 1(完整程序包) https://www.microsoft.com/zh-cn/download/details.aspx?id=25 ...
- 利用curl 模拟多线程
所谓多线程就是多个 程序同时运行,单线程:执行一段逻辑,等待完成后 在执行另外一个. 多线程:几个逻辑同时进行处理,不需要相互等待,提高了总的执行时间 接下来就用curl实现多线程 实现逻辑 1. f ...
- Aysnc的异步执行的线程池
ProxyAsyncConfiguration.java源码: @Configuration @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public clas ...
- 学习笔记之Git / Gitflow / TortoiseGit
Git - Wikipedia https://en.wikipedia.org/wiki/Git Git (/ɡɪt/) is a version control system for tracki ...
- org.apache.ibatis.binding.BindingException: Parameter 'idList' not found解决办法
https://blog.csdn.net/qq_28379809/article/details/83342196 问题描述 使用Mybatis查询数据库报错: org.apache.ibatis. ...
- go中的map[Interface{}]Interface{}理解
map里面的k,v支持很多的类型.对于go来说也是,go中有个接口的概念,任何对象都实现了一个空接口.那么我们把map里面的k,v都用interface去定义,当我们在使用这个map的时候,我们可以把 ...