Use a member variable for the list of verts to stop garbage generation.

release
Eddy Parris 2017-12-07 13:34:55 +00:00
parent d3671c3711
commit fbfb5afc8e
1 changed files with 32 additions and 28 deletions

View File

@ -1,4 +1,4 @@
/// Credit Melang
/// Credit Melang
/// Sourced from - http://forum.unity3d.com/members/melang.593409/
using System.Collections.Generic;
@ -16,6 +16,9 @@ namespace UnityEngine.UI.Extensions
[SerializeField]
private bool m_UseGraphicAlpha = true;
private List < UIVertex > m_Verts = new List<UIVertex>();
//
// Properties
//
@ -128,8 +131,9 @@ namespace UnityEngine.UI.Extensions
{
return;
}
List < UIVertex > verts = new List<UIVertex>();
vh.GetUIVertexStream(verts);
m_Verts.Clear();
vh.GetUIVertexStream(m_Verts);
Text foundtext = GetComponent<Text>();
@ -145,34 +149,34 @@ namespace UnityEngine.UI.Extensions
float distanceY = this.effectDistance.y * best_fit_adjustment;
int start = 0;
int count = verts.Count;
this.ApplyShadow (verts, this.effectColor, start, verts.Count, distanceX, distanceY);
int count = m_Verts.Count;
this.ApplyShadow (m_Verts, this.effectColor, start, m_Verts.Count, distanceX, distanceY);
start = count;
count = verts.Count;
this.ApplyShadow (verts, this.effectColor, start, verts.Count, distanceX, -distanceY);
count = m_Verts.Count;
this.ApplyShadow (m_Verts, this.effectColor, start, m_Verts.Count, distanceX, -distanceY);
start = count;
count = verts.Count;
this.ApplyShadow (verts, this.effectColor, start, verts.Count, -distanceX, distanceY);
count = m_Verts.Count;
this.ApplyShadow (m_Verts, this.effectColor, start, m_Verts.Count, -distanceX, distanceY);
start = count;
count = verts.Count;
this.ApplyShadow (verts, this.effectColor, start, verts.Count, -distanceX, -distanceY);
count = m_Verts.Count;
this.ApplyShadow (m_Verts, this.effectColor, start, m_Verts.Count, -distanceX, -distanceY);
start = count;
count = verts.Count;
this.ApplyShadow (verts, this.effectColor, start, verts.Count, distanceX, 0);
count = m_Verts.Count;
this.ApplyShadow (m_Verts, this.effectColor, start, m_Verts.Count, distanceX, 0);
start = count;
count = verts.Count;
this.ApplyShadow (verts, this.effectColor, start, verts.Count, -distanceX, 0);
count = m_Verts.Count;
this.ApplyShadow (m_Verts, this.effectColor, start, m_Verts.Count, -distanceX, 0);
start = count;
count = verts.Count;
this.ApplyShadow (verts, this.effectColor, start, verts.Count, 0, distanceY);
count = m_Verts.Count;
this.ApplyShadow (m_Verts, this.effectColor, start, m_Verts.Count, 0, distanceY);
start = count;
count = verts.Count;
this.ApplyShadow (verts, this.effectColor, start, verts.Count, 0, -distanceY);
count = m_Verts.Count;
this.ApplyShadow (m_Verts, this.effectColor, start, m_Verts.Count, 0, -distanceY);
vh.Clear();
vh.AddUIVertexTriangleStream(verts);
vh.AddUIVertexTriangleStream(m_Verts);
}
#if UNITY_EDITOR