Here are the examples of the csharp api UnityEngine.UI.Extensions.UICornerCut.AddSquare(UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.Rect, UnityEngine.Color32, UnityEngine.UI.VertexHelper) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
View Source File : UICornerCut.cs
License : MIT License
Project Creator : cmaher
License : MIT License
Project Creator : cmaher
protected override void OnPopulateMesh(VertexHelper vh)
{
var rect = rectTransform.rect;
var rectNew = rect;
Color32 color32 = color;
bool up = m_cutUL | m_cutUR;
bool down = m_cutLL | m_cutLR;
bool left = m_cutLL | m_cutUL;
bool right = m_cutLR | m_cutUR;
bool any = up | down;
if (any && cornerSize.sqrMagnitude > 0)
{
//nibble off the sides
vh.Clear();
if (left)
rectNew.xMin += cornerSize.x;
if (down)
rectNew.yMin += cornerSize.y;
if (up)
rectNew.yMax -= cornerSize.y;
if (right)
rectNew.xMax -= cornerSize.x;
//add two squares to the main square
Vector2 ul, ur, ll, lr;
if (m_makeColumns)
{
ul = new Vector2(rect.xMin, m_cutUL ? rectNew.yMax : rect.yMax);
ur = new Vector2(rect.xMax, m_cutUR ? rectNew.yMax : rect.yMax);
ll = new Vector2(rect.xMin, m_cutLL ? rectNew.yMin : rect.yMin);
lr = new Vector2(rect.xMax, m_cutLR ? rectNew.yMin : rect.yMin);
if (left)
AddSquare(
ll, ul,
new Vector2(rectNew.xMin, rect.yMax),
new Vector2(rectNew.xMin, rect.yMin),
rect, m_useColorUp ? m_colorUp : color32, vh);
if (right)
AddSquare(
ur, lr,
new Vector2(rectNew.xMax, rect.yMin),
new Vector2(rectNew.xMax, rect.yMax),
rect, m_useColorDown ? m_colorDown : color32, vh);
}
else
{
ul = new Vector2(m_cutUL ? rectNew.xMin : rect.xMin, rect.yMax);
ur = new Vector2(m_cutUR ? rectNew.xMax : rect.xMax, rect.yMax);
ll = new Vector2(m_cutLL ? rectNew.xMin : rect.xMin, rect.yMin);
lr = new Vector2(m_cutLR ? rectNew.xMax : rect.xMax, rect.yMin);
if (down)
AddSquare(
lr, ll,
new Vector2(rect.xMin, rectNew.yMin),
new Vector2(rect.xMax, rectNew.yMin),
rect, m_useColorDown ? m_colorDown : color32, vh);
if (up)
AddSquare(
ul, ur,
new Vector2(rect.xMax, rectNew.yMax),
new Vector2(rect.xMin, rectNew.yMax),
rect, m_useColorUp ? m_colorUp : color32, vh);
}
//center
if (m_makeColumns)
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);
}
}