You've already forked taptap2024_GJ_chidouren
init
This commit is contained in:
67
Assets/3rd/UIEffect/Scripts/UIFlip.cs
Normal file
67
Assets/3rd/UIEffect/Scripts/UIFlip.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("UI/UIEffects/UIFlip", 102)]
|
||||
public class UIFlip : BaseMeshEffect
|
||||
{
|
||||
[Tooltip("Flip horizontally.")] [SerializeField]
|
||||
private bool m_Horizontal = false;
|
||||
|
||||
[Tooltip("Flip vertically.")] [SerializeField]
|
||||
private bool m_Veritical = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="Coffee.UIEffects.UIFlip"/> should be flipped horizontally.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if be flipped horizontally; otherwise, <c>false</c>.</value>
|
||||
public bool horizontal
|
||||
{
|
||||
get { return this.m_Horizontal; }
|
||||
set
|
||||
{
|
||||
if (this.m_Horizontal == value) return;
|
||||
this.m_Horizontal = value;
|
||||
SetEffectParamsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="Coffee.UIEffects.UIFlip"/> should be flipped vertically.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if be flipped horizontally; otherwise, <c>false</c>.</value>
|
||||
public bool vertical
|
||||
{
|
||||
get { return this.m_Veritical; }
|
||||
set
|
||||
{
|
||||
if (this.m_Veritical == value) return;
|
||||
this.m_Veritical = value;
|
||||
SetEffectParamsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call used to modify mesh.
|
||||
/// </summary>
|
||||
/// <param name="vh">VertexHelper.</param>
|
||||
public override void ModifyMesh(VertexHelper vh, Graphic graphic)
|
||||
{
|
||||
if (!this.isActiveAndEnabled) return;
|
||||
|
||||
var vt = default(UIVertex);
|
||||
for (var i = 0; i < vh.currentVertCount; i++)
|
||||
{
|
||||
vh.PopulateUIVertex(ref vt, i);
|
||||
var pos = vt.position;
|
||||
vt.position = new Vector3(this.m_Horizontal ? -pos.x : pos.x, this.m_Veritical ? -pos.y : pos.y
|
||||
);
|
||||
vh.SetUIVertex(vt, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user