File size: 3,098 Bytes
18a519f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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]);
            }
        }
    }
}