暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GraphicTestHelper.cs 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System.Collections.Generic;
  2. using NUnit.Framework;
  3. namespace UnityEngine.UI.Tests
  4. {
  5. static class GraphicTestHelper
  6. {
  7. public static void TestOnPopulateMeshDefaultBehavior(Graphic graphic, VertexHelper vh)
  8. {
  9. Assert.AreEqual(4, vh.currentVertCount);
  10. List<UIVertex> verts = new List<UIVertex>();
  11. vh.GetUIVertexStream(verts);
  12. // The vertices for the 2 triangles of the canvas
  13. UIVertex[] expectedVertices =
  14. {
  15. new UIVertex
  16. {
  17. color = graphic.color,
  18. position = new Vector3(graphic.rectTransform.rect.x, graphic.rectTransform.rect.y),
  19. uv0 = new Vector2(0f, 0f),
  20. normal = new Vector3(0, 0, -1),
  21. tangent = new Vector4(1, 0, 0, -1)
  22. },
  23. new UIVertex
  24. {
  25. color = graphic.color,
  26. position = new Vector3(graphic.rectTransform.rect.x, graphic.rectTransform.rect.y + graphic.rectTransform.rect.height),
  27. uv0 = new Vector2(0f, 1f),
  28. normal = new Vector3(0, 0, -1),
  29. tangent = new Vector4(1, 0, 0, -1)
  30. },
  31. new UIVertex
  32. {
  33. color = graphic.color,
  34. position = new Vector3(graphic.rectTransform.rect.x + graphic.rectTransform.rect.width, graphic.rectTransform.rect.y + graphic.rectTransform.rect.height),
  35. uv0 = new Vector2(1f, 1f),
  36. normal = new Vector3(0, 0, -1),
  37. tangent = new Vector4(1, 0, 0, -1)
  38. },
  39. new UIVertex
  40. {
  41. color = graphic.color,
  42. position = new Vector3(graphic.rectTransform.rect.x + graphic.rectTransform.rect.width, graphic.rectTransform.rect.y + graphic.rectTransform.rect.height),
  43. uv0 = new Vector2(1f, 1f),
  44. normal = new Vector3(0, 0, -1),
  45. tangent = new Vector4(1, 0, 0, -1)
  46. },
  47. new UIVertex
  48. {
  49. color = graphic.color,
  50. position = new Vector3(graphic.rectTransform.rect.x + graphic.rectTransform.rect.width, graphic.rectTransform.rect.y),
  51. uv0 = new Vector2(1f, 0f),
  52. normal = new Vector3(0, 0, -1),
  53. tangent = new Vector4(1, 0, 0, -1)
  54. },
  55. new UIVertex
  56. {
  57. color = graphic.color,
  58. position = new Vector3(graphic.rectTransform.rect.x, graphic.rectTransform.rect.y),
  59. uv0 = new Vector2(0f, 0f),
  60. normal = new Vector3(0, 0, -1),
  61. tangent = new Vector4(1, 0, 0, -1)
  62. },
  63. };
  64. for (int i = 0; i < verts.Count; i++)
  65. {
  66. Assert.AreEqual(expectedVertices[i], verts[i]);
  67. }
  68. }
  69. }
  70. }