博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UGUI镜像翻转Image
阅读量:3566 次
发布时间:2019-05-20

本文共 1675 字,大约阅读时间需要 5 分钟。

namespace UnityEngine.UI.Extensions{    [RequireComponent(typeof(RectTransform), typeof(Graphic)), DisallowMultipleComponent]    [AddComponentMenu("UI/Effects/Extensions/Flippable")]    public class UIFlippable : MonoBehaviour, IMeshModifier    {             [SerializeField] private bool _horizontal = false;        [SerializeField] private bool _veritical = false;             public bool horizontal        {            get { return _horizontal; }            set { _horizontal = value; OnValidate(); }        }             public bool vertical        {            get { return _veritical; }            set { _veritical = value; OnValidate(); }        }             protected void OnValidate()        {            GetComponent
().SetVerticesDirty(); } public void ModifyMesh(VertexHelper verts) { RectTransform rt = transform as RectTransform; for (int i = 0; i < verts.currentVertCount; ++i) { UIVertex uiVertex = new UIVertex(); verts.PopulateUIVertex(ref uiVertex,i); // Modify positions uiVertex.position = new Vector3( (_horizontal ? (uiVertex.position.x + (rt.rect.center.x - uiVertex.position.x) * 2) : uiVertex.position.x), (_veritical ? (uiVertex.position.y + (rt.rect.center.y - uiVertex.position.y) * 2) : uiVertex.position.y), uiVertex.position.z ); // Apply verts.SetUIVertex(uiVertex, i); } } public void ModifyMesh(Mesh mesh) { //Obsolete member implementation } }}

 

转载地址:http://onerj.baihongyu.com/

你可能感兴趣的文章
Omap138开发板下以uboot2012.04.01为例分析uboot执行(五)
查看>>
Omap138开发板下以uboot2012.04.01为例分析uboot执行(六)
查看>>
Omap138开发板下以uboot2012.04.01为例分析uboot执行(七)
查看>>
Omap138开发板下以uboot2012.04.01为例分析uboot执行(八)
查看>>
Java发送邮件 注册成功发送邮件
查看>>
Mybatis的简单使用(增删改查),解决数据库字段名和实体类映射属性名不一致的问题
查看>>
Mybatis配置log4j文件 分页查询(limit,rowBounds)
查看>>
Mysql利用注解进行开发
查看>>
Mybatis一对多查询,多对一查询
查看>>
Spring配置bean.xml文件的头目录模板
查看>>
代理模式之------动态代理
查看>>
Spring实现AOP的三种方式
查看>>
Mybatis-Spring简单的配置和使用,配置事务
查看>>
SpringMVC和Mybatis整合使用的配置文件
查看>>
将字符串 “k:1|k1:2|k2:3|k3:4” 转换成字典{“k”:1,”k1”:2,”k2”:3,”k3”:4}
查看>>
AttributeError: 'tuple' object has no attribute 'decode'
查看>>
node爬虫(牛刀小试)
查看>>
关于vue的seo优化
查看>>
字符串在html中的页面中的换行
查看>>
react父子组件间的通信和传值
查看>>