Created
August 1, 2024 08:26
-
-
Save RimuruDev/716340bc7d80b7e02d1716928da0f3c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
public class VerticalGradient : BaseMeshEffect | |
{ | |
public Color topColor = Color.white; | |
public Color bottomColor = Color.white; | |
public override void ModifyMesh(VertexHelper vertexHelper) | |
{ | |
if (this.enabled) | |
{ | |
UIVertex vertex = default; | |
float[] t = new float[4] { 0f, 1f, 1f, 0f }; | |
for (int i = 0; i < vertexHelper.currentVertCount; i++) | |
{ | |
vertexHelper.PopulateUIVertex(ref vertex, i); | |
vertex.color *= Color.Lerp(this.bottomColor, this.topColor, t[i]); | |
vertexHelper.SetUIVertex(vertex, i); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment