ImagePlus.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. public class ImagePlus : Image
  6. {
  7. #region 变量
  8. public Text Text
  9. {
  10. get
  11. {
  12. if (_Text == null)
  13. {
  14. _Text = GetComponentInParent<Text>();
  15. }
  16. return _Text;
  17. }
  18. set { _Text = value; }
  19. }
  20. private Text _Text;
  21. public bool Draw;
  22. public List<UIVertex> VertexList;
  23. #endregion
  24. public void UpdateStatus(bool draw, VertexHelper vase, List<UIVertex> vertexList)
  25. {
  26. Draw = draw;
  27. VertexList = vertexList;
  28. OnPopulateMesh(vase);
  29. StartCoroutine
  30. (
  31. Auxiliary.IDelayCall
  32. (
  33. () =>
  34. {
  35. SetVerticesDirty();
  36. },
  37. 2
  38. )
  39. );
  40. }
  41. protected override void OnPopulateMesh(VertexHelper toFill)
  42. {
  43. toFill.Clear();
  44. if (VertexList.Valid() && Draw)
  45. {
  46. toFill.AddVert(VertexList[0]);
  47. toFill.AddVert(VertexList[1]);
  48. toFill.AddVert(VertexList[2]);
  49. toFill.AddVert(VertexList[3]);
  50. toFill.AddTriangle(0, 1, 2);
  51. toFill.AddTriangle(0, 2, 3);
  52. }
  53. }
  54. }