parent
92f5e2190d
commit
7e279b78a1
|
@ -9,6 +9,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Image is a textured element in the UI hierarchy.
|
/// Image is a textured element in the UI hierarchy.
|
||||||
|
/// Non-Functional as of 5.2.1p+ / 5.3, need to see updated Image Base script updates to fix properly.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[AddComponentMenu("UI/Extensions/Image Extended")]
|
[AddComponentMenu("UI/Extensions/Image Extended")]
|
||||||
|
@ -196,7 +197,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
var size = overrideSprite == null ? Vector2.zero : new Vector2(overrideSprite.rect.width, overrideSprite.rect.height);
|
var size = overrideSprite == null ? Vector2.zero : new Vector2(overrideSprite.rect.width, overrideSprite.rect.height);
|
||||||
|
|
||||||
Rect r = GetPixelAdjustedRect();
|
Rect r = GetPixelAdjustedRect();
|
||||||
// Debug.Log(string.Format("r:{2}, size:{0}, padding:{1}", size, padding, r));
|
|
||||||
|
|
||||||
int spriteW = Mathf.RoundToInt(size.x);
|
int spriteW = Mathf.RoundToInt(size.x);
|
||||||
int spriteH = Mathf.RoundToInt(size.y);
|
int spriteH = Mathf.RoundToInt(size.y);
|
||||||
|
@ -253,13 +253,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
/// Update the UI renderer mesh.
|
/// Update the UI renderer mesh.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
protected override void OnPopulateMesh(Mesh toFill)
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
{
|
{
|
||||||
List<UIVertex> vbo = new List<UIVertex>();
|
List<UIVertex> vbo = new List<UIVertex>();
|
||||||
using (var helper = new VertexHelper(toFill))
|
vh.GetUIVertexStream(vbo);
|
||||||
{
|
|
||||||
helper.GetUIVertexStream(vbo);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
@ -276,12 +273,8 @@ namespace UnityEngine.UI.Extensions
|
||||||
GenerateFilledSprite(vbo, m_PreserveAspect);
|
GenerateFilledSprite(vbo, m_PreserveAspect);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
vh.Clear();
|
||||||
using (var helper = new VertexHelper())
|
vh.AddUIVertexTriangleStream(vbo);
|
||||||
{
|
|
||||||
helper.AddUIVertexTriangleStream(vbo);
|
|
||||||
helper.FillMesh(toFill);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Various fill functions
|
#region Various fill functions
|
||||||
|
|
|
@ -46,7 +46,9 @@ using System.Collections.Generic;
|
||||||
namespace UnityEngine.UI.Extensions
|
namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
[AddComponentMenu("UI/Effects/Extensions/Letter Spacing")]
|
[AddComponentMenu("UI/Effects/Extensions/Letter Spacing")]
|
||||||
public class LetterSpacing : BaseMeshEffect
|
///Summary
|
||||||
|
/// Note, LetterSpacing is now non-functional in 5.2.1p+ / 5.3, seems the vertex order has changed?
|
||||||
|
public class LetterSpacing : BaseMeshEffect
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private float m_spacing = 0f;
|
private float m_spacing = 0f;
|
||||||
|
|
|
@ -15,8 +15,9 @@ namespace UnityEngine.UI.Extensions
|
||||||
public float c = 1;
|
public float c = 1;
|
||||||
public float d = 1;
|
public float d = 1;
|
||||||
|
|
||||||
protected override void OnPopulateMesh(Mesh m)
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
{
|
{
|
||||||
|
vh.Clear();
|
||||||
float wHalf = rectTransform.rect.width / 2;
|
float wHalf = rectTransform.rect.width / 2;
|
||||||
//float hHalf = rectTransform.rect.height / 2;
|
//float hHalf = rectTransform.rect.height / 2;
|
||||||
a = Math.Min(1, Math.Max(0, a));
|
a = Math.Min(1, Math.Max(0, a));
|
||||||
|
@ -25,17 +26,13 @@ namespace UnityEngine.UI.Extensions
|
||||||
d = Math.Min(1, Math.Max(0, d));
|
d = Math.Min(1, Math.Max(0, d));
|
||||||
|
|
||||||
Color32 color32 = color;
|
Color32 color32 = color;
|
||||||
using (var vh = new VertexHelper())
|
vh.AddVert(new Vector3(-wHalf * a, 0), color32, new Vector2(0f, 0f));
|
||||||
{
|
vh.AddVert(new Vector3(0, wHalf * b), color32, new Vector2(0f, 1f));
|
||||||
vh.AddVert(new Vector3(-wHalf * a, 0), color32, new Vector2(0f, 0f));
|
vh.AddVert(new Vector3(wHalf * c, 0), color32, new Vector2(1f, 1f));
|
||||||
vh.AddVert(new Vector3(0, wHalf * b), color32, new Vector2(0f, 1f));
|
vh.AddVert(new Vector3(0, -wHalf * d), color32, new Vector2(1f, 0f));
|
||||||
vh.AddVert(new Vector3(wHalf * c, 0), color32, new Vector2(1f, 1f));
|
|
||||||
vh.AddVert(new Vector3(0, -wHalf * d), color32, new Vector2(1f, 0f));
|
|
||||||
|
|
||||||
vh.AddTriangle(0, 1, 2);
|
vh.AddTriangle(0, 1, 2);
|
||||||
vh.AddTriangle(2, 3, 0);
|
vh.AddTriangle(2, 3, 0);
|
||||||
vh.FillMesh(m);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -67,13 +67,12 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void OnPopulateMesh(Mesh toFill)
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
{
|
{
|
||||||
float outer = -rectTransform.pivot.x * rectTransform.rect.width;
|
float outer = -rectTransform.pivot.x * rectTransform.rect.width;
|
||||||
float inner = -rectTransform.pivot.x * rectTransform.rect.width + this.thickness;
|
float inner = -rectTransform.pivot.x * rectTransform.rect.width + this.thickness;
|
||||||
|
|
||||||
toFill.Clear();
|
vh.Clear();
|
||||||
var vbo = new VertexHelper(toFill);
|
|
||||||
|
|
||||||
Vector2 prevX = Vector2.zero;
|
Vector2 prevX = Vector2.zero;
|
||||||
Vector2 prevY = Vector2.zero;
|
Vector2 prevY = Vector2.zero;
|
||||||
|
@ -119,15 +118,9 @@ namespace UnityEngine.UI.Extensions
|
||||||
prevX = pos1;
|
prevX = pos1;
|
||||||
prevY = pos2;
|
prevY = pos2;
|
||||||
|
|
||||||
vbo.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 }));
|
vh.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 }));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vbo.currentVertCount > 3)
|
|
||||||
{
|
|
||||||
vbo.FillMesh(toFill);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,156 +1,159 @@
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Created by Freezy - ElicitIce.nl
|
/// Created by Freezy - ElicitIce.nl
|
||||||
/// Posted on Unity Forums http://forum.unity3d.com/threads/cut-corners-primative.359494/
|
/// Posted on Unity Forums http://forum.unity3d.com/threads/cut-corners-primative.359494/
|
||||||
///
|
///
|
||||||
/// Free for any use and alteration, source code may not be sold without my permission.
|
/// Free for any use and alteration, source code may not be sold without my permission.
|
||||||
/// If you make improvements on this script please share them with the community.
|
/// If you make improvements on this script please share them with the community.
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// Here is a script that will take a rectangular TransformRect and cut off some corners based on the corner size.
|
/// Here is a script that will take a rectangular TransformRect and cut off some corners based on the corner size.
|
||||||
/// This is great for when you need a quick and easy non-square panel/image.
|
/// This is great for when you need a quick and easy non-square panel/image.
|
||||||
/// Enjoy!
|
/// Enjoy!
|
||||||
/// It adds an additional square if the relevant side has a corner cut, it then offsets the ends to simulate a cut corner.
|
/// It adds an additional square if the relevant side has a corner cut, it then offsets the ends to simulate a cut corner.
|
||||||
/// UVs are being set, but might be skewed when a texture is applied.
|
/// UVs are being set, but might be skewed when a texture is applied.
|
||||||
/// You could hide the additional colors by using the following:
|
/// You could hide the additional colors by using the following:
|
||||||
/// http://rumorgames.com/hide-in-inspector/
|
/// http://rumorgames.com/hide-in-inspector/
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
namespace UnityEngine.UI.Extensions {
|
namespace UnityEngine.UI.Extensions {
|
||||||
[ExecuteInEditMode]
|
[ExecuteInEditMode]
|
||||||
[AddComponentMenu("UI/Extensions/Primitives/Cut Corners")]
|
[AddComponentMenu("UI/Extensions/Primitives/Cut Corners")]
|
||||||
public class UICornerCut : MaskableGraphic {
|
public class UICornerCut : MaskableGraphic {
|
||||||
|
|
||||||
public Vector2 cornerSize = new Vector2(16, 16);
|
public Vector2 cornerSize = new Vector2(16, 16);
|
||||||
|
|
||||||
[Header("Corners to cut")]
|
[Header("Corners to cut")]
|
||||||
public bool cutUL = true;
|
public bool cutUL = true;
|
||||||
public bool cutUR;
|
public bool cutUR;
|
||||||
public bool cutLL;
|
public bool cutLL;
|
||||||
public bool cutLR;
|
public bool cutLR;
|
||||||
|
|
||||||
[Tooltip("Up-Down colors become Left-Right colors")]
|
[Tooltip("Up-Down colors become Left-Right colors")]
|
||||||
public bool makeColumns = false;
|
public bool makeColumns = false;
|
||||||
|
|
||||||
[Header("Color the cut bars differently")]
|
[Header("Color the cut bars differently")]
|
||||||
public bool useColorUp;
|
public bool useColorUp;
|
||||||
// [HideUnless("useColorUp")]
|
// [HideUnless("useColorUp")]
|
||||||
public Color32 colorUp = Color.blue;
|
public Color32 colorUp = Color.blue;
|
||||||
|
|
||||||
public bool useColorDown;
|
public bool useColorDown;
|
||||||
// [HideUnless("useColorDown")]
|
// [HideUnless("useColorDown")]
|
||||||
public Color32 colorDown = Color.green;
|
public Color32 colorDown = Color.green;
|
||||||
|
|
||||||
protected override void OnPopulateMesh(Mesh m) {
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
var rect = rectTransform.rect;
|
{
|
||||||
var rectNew = rect;
|
var rect = rectTransform.rect;
|
||||||
|
var rectNew = rect;
|
||||||
Color32 color32 = color;
|
|
||||||
using (var vh = new VertexHelper()) {
|
Color32 color32 = color;
|
||||||
bool up = cutUL | cutUR;
|
bool up = cutUL | cutUR;
|
||||||
bool down = cutLL | cutLR;
|
bool down = cutLL | cutLR;
|
||||||
bool left = cutLL | cutUL;
|
bool left = cutLL | cutUL;
|
||||||
bool right = cutLR | cutUR;
|
bool right = cutLR | cutUR;
|
||||||
bool any = up | down;
|
bool any = up | down;
|
||||||
|
|
||||||
if (any && cornerSize.sqrMagnitude > 0) {
|
if (any && cornerSize.sqrMagnitude > 0)
|
||||||
//nibble off the sides
|
{
|
||||||
|
|
||||||
if (left)
|
//nibble off the sides
|
||||||
rectNew.xMin += cornerSize.x;
|
vh.Clear();
|
||||||
if (down)
|
if (left)
|
||||||
rectNew.yMin += cornerSize.y;
|
rectNew.xMin += cornerSize.x;
|
||||||
if (up)
|
if (down)
|
||||||
rectNew.yMax -= cornerSize.y;
|
rectNew.yMin += cornerSize.y;
|
||||||
if (right)
|
if (up)
|
||||||
rectNew.xMax -= cornerSize.x;
|
rectNew.yMax -= cornerSize.y;
|
||||||
|
if (right)
|
||||||
//add two squares to the main square
|
rectNew.xMax -= cornerSize.x;
|
||||||
Vector2 ul, ur, ll, lr;
|
|
||||||
|
//add two squares to the main square
|
||||||
if (makeColumns) {
|
Vector2 ul, ur, ll, lr;
|
||||||
ul = new Vector2(rect.xMin, cutUL ? rectNew.yMax : rect.yMax);
|
|
||||||
ur = new Vector2(rect.xMax, cutUR ? rectNew.yMax : rect.yMax);
|
if (makeColumns)
|
||||||
ll = new Vector2(rect.xMin, cutLL ? rectNew.yMin : rect.yMin);
|
{
|
||||||
lr = new Vector2(rect.xMax, cutLR ? rectNew.yMin : rect.yMin);
|
ul = new Vector2(rect.xMin, cutUL ? rectNew.yMax : rect.yMax);
|
||||||
|
ur = new Vector2(rect.xMax, cutUR ? rectNew.yMax : rect.yMax);
|
||||||
if (left)
|
ll = new Vector2(rect.xMin, cutLL ? rectNew.yMin : rect.yMin);
|
||||||
AddSquare(
|
lr = new Vector2(rect.xMax, cutLR ? rectNew.yMin : rect.yMin);
|
||||||
ll, ul,
|
|
||||||
new Vector2(rectNew.xMin, rect.yMax),
|
if (left)
|
||||||
new Vector2(rectNew.xMin, rect.yMin),
|
AddSquare(
|
||||||
rect, useColorUp ? colorUp : color32, vh);
|
ll, ul,
|
||||||
if (right)
|
new Vector2(rectNew.xMin, rect.yMax),
|
||||||
AddSquare(
|
new Vector2(rectNew.xMin, rect.yMin),
|
||||||
ur, lr,
|
rect, useColorUp ? colorUp : color32, vh);
|
||||||
new Vector2(rectNew.xMax, rect.yMin),
|
if (right)
|
||||||
new Vector2(rectNew.xMax, rect.yMax),
|
AddSquare(
|
||||||
rect, useColorDown ? colorDown : color32, vh);
|
ur, lr,
|
||||||
} else {
|
new Vector2(rectNew.xMax, rect.yMin),
|
||||||
ul = new Vector2(cutUL ? rectNew.xMin : rect.xMin, rect.yMax);
|
new Vector2(rectNew.xMax, rect.yMax),
|
||||||
ur = new Vector2(cutUR ? rectNew.xMax : rect.xMax, rect.yMax);
|
rect, useColorDown ? colorDown : color32, vh);
|
||||||
ll = new Vector2(cutLL ? rectNew.xMin : rect.xMin, rect.yMin);
|
}
|
||||||
lr = new Vector2(cutLR ? rectNew.xMax : rect.xMax, rect.yMin);
|
else
|
||||||
if (down)
|
{
|
||||||
AddSquare(
|
ul = new Vector2(cutUL ? rectNew.xMin : rect.xMin, rect.yMax);
|
||||||
lr, ll,
|
ur = new Vector2(cutUR ? rectNew.xMax : rect.xMax, rect.yMax);
|
||||||
new Vector2(rect.xMin, rectNew.yMin),
|
ll = new Vector2(cutLL ? rectNew.xMin : rect.xMin, rect.yMin);
|
||||||
new Vector2(rect.xMax, rectNew.yMin),
|
lr = new Vector2(cutLR ? rectNew.xMax : rect.xMax, rect.yMin);
|
||||||
rect, useColorDown ? colorDown : color32, vh);
|
if (down)
|
||||||
if (up)
|
AddSquare(
|
||||||
AddSquare(
|
lr, ll,
|
||||||
ul, ur,
|
new Vector2(rect.xMin, rectNew.yMin),
|
||||||
new Vector2(rect.xMax, rectNew.yMax),
|
new Vector2(rect.xMax, rectNew.yMin),
|
||||||
new Vector2(rect.xMin, rectNew.yMax),
|
rect, useColorDown ? colorDown : color32, vh);
|
||||||
rect, useColorUp ? colorUp : color32, vh);
|
if (up)
|
||||||
}
|
AddSquare(
|
||||||
}
|
ul, ur,
|
||||||
|
new Vector2(rect.xMax, rectNew.yMax),
|
||||||
//center
|
new Vector2(rect.xMin, rectNew.yMax),
|
||||||
if (makeColumns)
|
rect, useColorUp ? colorUp : color32, vh);
|
||||||
AddSquare(new Rect(rectNew.xMin, rect.yMin, rectNew.width, rect.height), rect, color32, vh);
|
}
|
||||||
else
|
|
||||||
AddSquare(new Rect(rect.xMin, rectNew.yMin, rect.width, rectNew.height), rect, color32, vh);
|
//center
|
||||||
|
if (makeColumns)
|
||||||
vh.FillMesh(m);
|
AddSquare(new Rect(rectNew.xMin, rect.yMin, rectNew.width, rect.height), rect, color32, vh);
|
||||||
}
|
else
|
||||||
}
|
AddSquare(new Rect(rect.xMin, rectNew.yMin, rect.width, rectNew.height), rect, color32, vh);
|
||||||
|
|
||||||
private static void AddSquare(Rect rect, Rect rectUV, Color32 color32, VertexHelper vh) {
|
}
|
||||||
int v0 = AddVert(rect.xMin, rect.yMin, rectUV, color32, vh);
|
}
|
||||||
int v1 = AddVert(rect.xMin, rect.yMax, rectUV, color32, vh);
|
|
||||||
int v2 = AddVert(rect.xMax, rect.yMax, rectUV, color32, vh);
|
private static void AddSquare(Rect rect, Rect rectUV, Color32 color32, VertexHelper vh) {
|
||||||
int v3 = AddVert(rect.xMax, rect.yMin, rectUV, color32, vh);
|
int v0 = AddVert(rect.xMin, rect.yMin, rectUV, color32, vh);
|
||||||
|
int v1 = AddVert(rect.xMin, rect.yMax, rectUV, color32, vh);
|
||||||
vh.AddTriangle(v0, v1, v2);
|
int v2 = AddVert(rect.xMax, rect.yMax, rectUV, color32, vh);
|
||||||
vh.AddTriangle(v2, v3, v0);
|
int v3 = AddVert(rect.xMax, rect.yMin, rectUV, color32, vh);
|
||||||
}
|
|
||||||
|
vh.AddTriangle(v0, v1, v2);
|
||||||
private static void AddSquare(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Rect rectUV, Color32 color32, VertexHelper vh) {
|
vh.AddTriangle(v2, v3, v0);
|
||||||
int v0 = AddVert(a.x, a.y, rectUV, color32, vh);
|
}
|
||||||
int v1 = AddVert(b.x, b.y, rectUV, color32, vh);
|
|
||||||
int v2 = AddVert(c.x, c.y, rectUV, color32, vh);
|
private static void AddSquare(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Rect rectUV, Color32 color32, VertexHelper vh) {
|
||||||
int v3 = AddVert(d.x, d.y, rectUV, color32, vh);
|
int v0 = AddVert(a.x, a.y, rectUV, color32, vh);
|
||||||
|
int v1 = AddVert(b.x, b.y, rectUV, color32, vh);
|
||||||
vh.AddTriangle(v0, v1, v2);
|
int v2 = AddVert(c.x, c.y, rectUV, color32, vh);
|
||||||
vh.AddTriangle(v2, v3, v0);
|
int v3 = AddVert(d.x, d.y, rectUV, color32, vh);
|
||||||
}
|
|
||||||
|
vh.AddTriangle(v0, v1, v2);
|
||||||
/// <summary>
|
vh.AddTriangle(v2, v3, v0);
|
||||||
/// Auto UV handler within the assigned area
|
}
|
||||||
/// </summary>
|
|
||||||
/// <param name="x"></param>
|
/// <summary>
|
||||||
/// <param name="y"></param>
|
/// Auto UV handler within the assigned area
|
||||||
/// <param name="area"></param>
|
/// </summary>
|
||||||
/// <param name="color32"></param>
|
/// <param name="x"></param>
|
||||||
/// <param name="vh"></param>
|
/// <param name="y"></param>
|
||||||
private static int AddVert(float x, float y, Rect area, Color32 color32, VertexHelper vh) {
|
/// <param name="area"></param>
|
||||||
var uv = new Vector2(
|
/// <param name="color32"></param>
|
||||||
Mathf.InverseLerp(area.xMin, area.xMax, x),
|
/// <param name="vh"></param>
|
||||||
Mathf.InverseLerp(area.yMin, area.yMax, y)
|
private static int AddVert(float x, float y, Rect area, Color32 color32, VertexHelper vh) {
|
||||||
);
|
var uv = new Vector2(
|
||||||
vh.AddVert(new Vector3(x, y), color32, uv);
|
Mathf.InverseLerp(area.xMin, area.xMax, x),
|
||||||
return vh.currentVertCount - 1;
|
Mathf.InverseLerp(area.yMin, area.yMax, y)
|
||||||
}
|
);
|
||||||
}
|
vh.AddVert(new Vector3(x, y), color32, uv);
|
||||||
|
return vh.currentVertCount - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -65,7 +65,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPopulateMesh(Mesh toFill)
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
{
|
{
|
||||||
// requires sets of quads
|
// requires sets of quads
|
||||||
if (Points == null || Points.Length < 2)
|
if (Points == null || Points.Length < 2)
|
||||||
|
@ -107,8 +107,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
offsetY += Margin.y / 2f;
|
offsetY += Margin.y / 2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
toFill.Clear();
|
vh.Clear();
|
||||||
var vbo = new VertexHelper(toFill);
|
|
||||||
|
|
||||||
Vector2 prevV1 = Vector2.zero;
|
Vector2 prevV1 = Vector2.zero;
|
||||||
Vector2 prevV2 = Vector2.zero;
|
Vector2 prevV2 = Vector2.zero;
|
||||||
|
@ -144,24 +143,19 @@ namespace UnityEngine.UI.Extensions
|
||||||
Vector2[] uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomCenter, uvTopCenter };
|
Vector2[] uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomCenter, uvTopCenter };
|
||||||
|
|
||||||
if (i > 1)
|
if (i > 1)
|
||||||
vbo.AddUIVertexQuad(SetVbo(new[] { prevV1, prevV2, v1, v2 }, uvs));
|
vh.AddUIVertexQuad(SetVbo(new[] { prevV1, prevV2, v1, v2 }, uvs));
|
||||||
|
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
uvs = new[] { uvTopLeft, uvBottomLeft, uvBottomCenter, uvTopCenter };
|
uvs = new[] { uvTopLeft, uvBottomLeft, uvBottomCenter, uvTopCenter };
|
||||||
else if (i == TempPoints.Length - 1)
|
else if (i == TempPoints.Length - 1)
|
||||||
uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomRight, uvTopRight };
|
uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomRight, uvTopRight };
|
||||||
|
|
||||||
vbo.AddUIVertexQuad(SetVbo(new[] { v1, v2, v3, v4 }, uvs));
|
vh.AddUIVertexQuad(SetVbo(new[] { v1, v2, v3, v4 }, uvs));
|
||||||
|
|
||||||
|
|
||||||
prevV1 = v3;
|
prevV1 = v3;
|
||||||
prevV2 = v4;
|
prevV2 = v4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vbo.currentVertCount > 3)
|
|
||||||
{
|
|
||||||
vbo.FillMesh(toFill);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs)
|
protected UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs)
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPopulateMesh(Mesh toFill)
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
{
|
{
|
||||||
// requires sets of quads
|
// requires sets of quads
|
||||||
if (Points == null || Points.Length < 2)
|
if (Points == null || Points.Length < 2)
|
||||||
|
@ -108,8 +108,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
offsetY += Margin.y / 2f;
|
offsetY += Margin.y / 2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
toFill.Clear();
|
vh.Clear();
|
||||||
var vbo = new VertexHelper(toFill);
|
|
||||||
|
|
||||||
Vector2 prevV1 = Vector2.zero;
|
Vector2 prevV1 = Vector2.zero;
|
||||||
Vector2 prevV2 = Vector2.zero;
|
Vector2 prevV2 = Vector2.zero;
|
||||||
|
@ -145,24 +144,19 @@ namespace UnityEngine.UI.Extensions
|
||||||
Vector2[] uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomCenter, uvTopCenter };
|
Vector2[] uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomCenter, uvTopCenter };
|
||||||
|
|
||||||
if (i > 1)
|
if (i > 1)
|
||||||
vbo.AddUIVertexQuad(SetVbo(new[] { prevV1, prevV2, v1, v2 }, uvs));
|
vh.AddUIVertexQuad(SetVbo(new[] { prevV1, prevV2, v1, v2 }, uvs));
|
||||||
|
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
uvs = new[] { uvTopLeft, uvBottomLeft, uvBottomCenter, uvTopCenter };
|
uvs = new[] { uvTopLeft, uvBottomLeft, uvBottomCenter, uvTopCenter };
|
||||||
else if (i == TempPoints.Length - 1)
|
else if (i == TempPoints.Length - 1)
|
||||||
uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomRight, uvTopRight };
|
uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomRight, uvTopRight };
|
||||||
|
|
||||||
vbo.AddUIVertexQuad(SetVbo(new[] { v1, v2, v3, v4 }, uvs));
|
vh.AddUIVertexQuad(SetVbo(new[] { v1, v2, v3, v4 }, uvs));
|
||||||
|
|
||||||
|
|
||||||
prevV1 = v3;
|
prevV1 = v3;
|
||||||
prevV2 = v4;
|
prevV2 = v4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vbo.currentVertCount > 3)
|
|
||||||
{
|
|
||||||
vbo.FillMesh(toFill);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs)
|
protected UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs)
|
||||||
|
|
Loading…
Reference in New Issue