UGUI|UGUI镜像翻转Image
https://blog.icemark.cn/?p=404
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
}
}
}
【UGUI|UGUI镜像翻转Image】
推荐阅读
- docker镜像探索----dive工具
- unity探究UGUI的Image中sprite和overrideSprite的区别
- CentOS7 阿里云镜像配置方法
- 2019-09-02|2019-09-02 镜像
- Windows10|Windows10,Version,1903,7月更新,MSDN镜像下载
- 华为可翻转全面屏手机专利亮相(折叠方式好比翻书一样)
- 【数组题】给定一个二进制矩阵|【数组题】给定一个二进制矩阵 A,我们想先水平翻转图像,然后反转图像并返回结果。
- 翻转课堂《DISC与团队建设》
- 制作jdk8|制作jdk8 Dockerfile
- 翻转式课堂读书分享