Class Shadow
Adds a drop shadow to a graphic by duplicating its mesh vertices, offsetting them by effectDistance, and recoloring them with effectColor.
Implements
Inherited Members
Namespace: UnityEngine.UI
Assembly: UnityEngine.UI.dll
Syntax
[AddComponentMenu("UI (Canvas)/Effects/Shadow", 80)]
public class Shadow : BaseMeshEffect, IMeshModifier
Constructors
Shadow()
Protected default constructor. Use UnityEngine.GameObject.AddComponent<T>() to add a Shadow to a GameObject.
Declaration
protected Shadow()
Properties
effectColor
Color for the effect
Declaration
public Color effectColor { get; set; }
Property Value
| Type | Description |
|---|---|
| Color |
effectDistance
How far is the shadow from the graphic.
Declaration
public Vector2 effectDistance { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
useGraphicAlpha
Should the shadow inherit the alpha from the graphic?
Declaration
public bool useGraphicAlpha { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
ApplyShadow(List<UIVertex>, Color32, int, int, float, float)
Duplicate vertices from start to end and turn them into shadows with the given offset.
Declaration
protected void ApplyShadow(List<UIVertex> verts, Color32 color, int start, int end, float x, float y)
Parameters
| Type | Name | Description |
|---|---|---|
| List<UIVertex> | verts | Vert list to copy |
| Color32 | color | Shadow color |
| int | start | The start index in the verts list |
| int | end | The end index in the vers list |
| float | x | The shadows x offset |
| float | y | The shadows y offset |
ApplyShadowZeroAlloc(List<UIVertex>, Color32, int, int, float, float)
Appends shadow copies of the vertices in verts from index start up to
(but not including) end, offset by (x, y) and
recolored with color. Pre-sizes the list capacity to avoid extra allocations.
Declaration
protected void ApplyShadowZeroAlloc(List<UIVertex> verts, Color32 color, int start, int end, float x, float y)
Parameters
| Type | Name | Description |
|---|---|---|
| List<UIVertex> | verts | The vertex list to append the shadow copies to. |
| Color32 | color | The color to apply to the shadow vertices. |
| int | start | The index of the first vertex in |
| int | end | The exclusive upper index of vertices in |
| float | x | Horizontal offset of the shadow. |
| float | y | Vertical offset of the shadow. |
ModifyMesh(VertexHelper)
Applies the shadow effect to the geometry held in vh by appending
offset, recolored copies of all current vertices behind the originals.
Declaration
public override void ModifyMesh(VertexHelper vh)
Parameters
| Type | Name | Description |
|---|---|---|
| VertexHelper | vh | The VertexHelper containing the graphic's mesh data to modify. |
Overrides
OnValidate()
Declaration
protected override void OnValidate()