Last active
July 1, 2021 20:13
-
-
Save bbeaumont/9537b52506fa171d062c to your computer and use it in GitHub Desktop.
Unity UI Bevel or Emboss effect
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 System.Collections.Generic; | |
namespace UnityEngine.UI | |
{ | |
[AddComponentMenu("UI/Effects/Bevel", 15)] | |
public class Bevel : Shadow | |
{ | |
[SerializeField] private Color highlightColor; | |
protected Bevel() | |
{ } | |
public override void ModifyVertices(List<UIVertex> verts) | |
{ | |
if (!IsActive()) | |
return; | |
var start = 0; | |
var end = verts.Count; | |
ApplyShadow(verts, highlightColor, start, verts.Count, -effectDistance.x, effectDistance.y); | |
start = end; | |
ApplyShadow(verts, effectColor, start, verts.Count, effectDistance.x, -effectDistance.y); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've updated the code to work in 2020.x version. Just create a class Bevel.cs and paste it. Then, add Bevel component to your UI Element.
Please note,
ListPool<T>
is an internal class of UnityEngine till 2021.1 version. So, if you're trying this in 2021.1 or more, please removeListPool<T>
andObjectPool<T>
.