暫無描述
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.

ImageFilledGenerateWork.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine.UI;
  2. using UnityEngine.TestTools;
  3. using NUnit.Framework;
  4. using System.Collections;
  5. using UnityEngine;
  6. [TestFixture]
  7. [Category("RegressionTest")]
  8. public class ImageFilledGenerateWork
  9. {
  10. GameObject m_CanvasGO;
  11. GameObject m_ImageGO;
  12. [SetUp]
  13. public void SetUp()
  14. {
  15. m_CanvasGO = new GameObject("Canvas");
  16. m_ImageGO = new GameObject("Image");
  17. }
  18. [Test]
  19. public void ImageFilledGenerateWorks()
  20. {
  21. m_CanvasGO.AddComponent<Canvas>();
  22. m_ImageGO.transform.SetParent(m_CanvasGO.transform);
  23. var image = m_ImageGO.AddComponent<TestableImage>();
  24. image.type = Image.Type.Filled;
  25. var texture = new Texture2D(32, 32);
  26. image.sprite = Sprite.Create(texture, new Rect(0, 0, 32, 32), Vector2.zero);
  27. image.fillMethod = Image.FillMethod.Horizontal;
  28. image.fillAmount = 0.5f;
  29. // Generate the image data now.
  30. VertexHelper vh = new VertexHelper();
  31. // Image is a "TestableImage" which has the Assert in the GenerateImageData as we need to validate
  32. // the data which is protected.
  33. image.GenerateImageData(vh);
  34. }
  35. [TearDown]
  36. public void TearDown()
  37. {
  38. GameObject.DestroyImmediate(m_CanvasGO);
  39. }
  40. }