ZMWSLI0-SL2021-GR11/Projekt/MWSProjekt/Library/PackageCache/com.unity.ugui@1.0.0/Tests/Runtime/Util/GraphicTestHelper.cs

74 lines
3.0 KiB
C#
Raw Normal View History

2021-07-05 21:20:56 +02:00
using System.Collections.Generic;
using NUnit.Framework;
namespace UnityEngine.UI.Tests
{
static class GraphicTestHelper
{
public static void TestOnPopulateMeshDefaultBehavior(Graphic graphic, VertexHelper vh)
{
Assert.AreEqual(4, vh.currentVertCount);
List<UIVertex> verts = new List<UIVertex>();
vh.GetUIVertexStream(verts);
// The vertices for the 2 triangles of the canvas
UIVertex[] expectedVertices =
{
new UIVertex
{
color = graphic.color,
position = new Vector3(graphic.rectTransform.rect.x, graphic.rectTransform.rect.y),
uv0 = new Vector2(0f, 0f),
normal = new Vector3(0, 0, -1),
tangent = new Vector4(1, 0, 0, -1)
},
new UIVertex
{
color = graphic.color,
position = new Vector3(graphic.rectTransform.rect.x, graphic.rectTransform.rect.y + graphic.rectTransform.rect.height),
uv0 = new Vector2(0f, 1f),
normal = new Vector3(0, 0, -1),
tangent = new Vector4(1, 0, 0, -1)
},
new UIVertex
{
color = graphic.color,
position = new Vector3(graphic.rectTransform.rect.x + graphic.rectTransform.rect.width, graphic.rectTransform.rect.y + graphic.rectTransform.rect.height),
uv0 = new Vector2(1f, 1f),
normal = new Vector3(0, 0, -1),
tangent = new Vector4(1, 0, 0, -1)
},
new UIVertex
{
color = graphic.color,
position = new Vector3(graphic.rectTransform.rect.x + graphic.rectTransform.rect.width, graphic.rectTransform.rect.y + graphic.rectTransform.rect.height),
uv0 = new Vector2(1f, 1f),
normal = new Vector3(0, 0, -1),
tangent = new Vector4(1, 0, 0, -1)
},
new UIVertex
{
color = graphic.color,
position = new Vector3(graphic.rectTransform.rect.x + graphic.rectTransform.rect.width, graphic.rectTransform.rect.y),
uv0 = new Vector2(1f, 0f),
normal = new Vector3(0, 0, -1),
tangent = new Vector4(1, 0, 0, -1)
},
new UIVertex
{
color = graphic.color,
position = new Vector3(graphic.rectTransform.rect.x, graphic.rectTransform.rect.y),
uv0 = new Vector2(0f, 0f),
normal = new Vector3(0, 0, -1),
tangent = new Vector4(1, 0, 0, -1)
},
};
for (int i = 0; i < verts.Count; i++)
{
Assert.AreEqual(expectedVertices[i], verts[i]);
}
}
}
}