[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竖排文字效果
文字效果
随机推荐
- Kafka使用log.retention.hours改变消息端的消息保存时间
数据存储的最大时间超过这个时间会根据log.cleanup.policy设置的策略处理数据,也就是消费端能够多久去消费数据log.retention.bytes和log.retention.hours ...
- RedHat6.5安装zookeeper单机
版本号: Redhat6.5 zookeeper-3.4.6 JDK1.8 zookeeper下载 官网下载地址:https://mirrors.tuna.tsinghua.edu.cn/apac ...
- mybatis 使用oracle merge into 语句踩坑实录
由于需求涉及oracle的clob类型字段,在mybatis的mapper xml文件中编写merge into语句时总是失败. 附上错误代码 <insert id="mergeInt ...
- php解析url并得到url中的参数及获取url参数
<?php $url = 'http://www.baidu.com/index.php?m=content&c=index&a=lists&catid=6&ar ...
- python cntl使用
import sys 2 import time 3 import fcntl 4 5 class FLOCK(object): 6 7 def __init__(self, name): 8 sel ...
- Team Foundation Server 2010简体中文版
文件名称:Team Foundation Server 2010简体中文版 文件大小:1.8 GBhttp://www.google.com/profiles/dedecms.com 下载地址: th ...
- mysql数据字典 如何生成?
用phpMyAdmin查看表结构,点击 打印预览. &lt;img src="https://pic3.zhimg.com/50/3205ff3bd3da067528f4c1 ...
- PHP操作mongoDB 笔记
转自 http://blog.csdn.net/black_ox/article/details/22678747 命令也可以在参考http://www.jb51.net/article/51601. ...
- 黄聪:VS2017调试时提示“运行时无法计算表达式的值”
具体操作: 工具-选项-调试-常规,选中“使用托管兼容模式”,问题解决
- PAT 乙级 1031 查验身份证(15) C++版
1031. 查验身份证(15) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 一个合法的身份证号码由17位地区. ...