4using System.Collections.Generic;
8 [AddComponentMenu(
"UI/Effects/Extensions/Nicer Outline")]
12 private Color m_EffectColor =
new Color (0f, 0f, 0f, 0.5f);
15 private Vector2 m_EffectDistance =
new Vector2 (1f, -1f);
18 private bool m_UseGraphicAlpha =
true;
20 private List < UIVertex > m_Verts =
new List<UIVertex>();
29 return this.m_EffectColor;
33 this.m_EffectColor = value;
34 if (base.graphic !=
null)
36 base.graphic.SetVerticesDirty ();
45 return this.m_EffectDistance;
65 if (this.m_EffectDistance == value)
69 this.m_EffectDistance = value;
70 if (base.graphic !=
null)
72 base.graphic.SetVerticesDirty ();
81 return this.m_UseGraphicAlpha;
85 this.m_UseGraphicAlpha = value;
86 if (base.graphic !=
null)
88 base.graphic.SetVerticesDirty ();
93 protected void ApplyShadowZeroAlloc(List<UIVertex> verts, Color32 color,
int start,
int end,
float x,
float y)
97 var neededCpacity = verts.Count * 2;
98 if (verts.Capacity < neededCpacity)
99 verts.Capacity = neededCpacity;
101 for (
int i = start; i < end; ++i)
106 Vector3 v = vt.position;
110 var newColor = color;
111 if (m_UseGraphicAlpha)
112 newColor.a = (byte)((newColor.a * verts[i].color.a) / 255);
118 protected void ApplyShadow(List<UIVertex> verts, Color32 color,
int start,
int end,
float x,
float y)
120 var neededCpacity = verts.Count * 2;
121 if (verts.Capacity < neededCpacity)
122 verts.Capacity = neededCpacity;
130 if (!this.IsActive ())
136 vh.GetUIVertexStream(m_Verts);
138 Text foundtext = GetComponent<Text>();
140 float best_fit_adjustment = 1f;
142 if (foundtext && foundtext.resizeTextForBestFit)
144 best_fit_adjustment = (float)foundtext.cachedTextGenerator.fontSizeUsedForBestFit / (foundtext.resizeTextMaxSize-1);
152 int count = m_Verts.Count;
155 count = m_Verts.Count;
158 count = m_Verts.Count;
161 count = m_Verts.Count;
165 count = m_Verts.Count;
168 count = m_Verts.Count;
172 count = m_Verts.Count;
175 count = m_Verts.Count;
179 vh.AddUIVertexTriangleStream(m_Verts);
183 protected override void OnValidate ()
override void ModifyMesh(VertexHelper vh)
void ApplyShadow(List< UIVertex > verts, Color32 color, int start, int end, float x, float y)
void ApplyShadowZeroAlloc(List< UIVertex > verts, Color32 color, int start, int end, float x, float y)
Credit Erdener Gonenc - @PixelEnvision.