ImagePlus.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. if (Draw)
  28. {
  29. if (Application.isPlaying)
  30. {
  31. sprite = Bundle.Atlas.LoadAsset<Sprite>("Atlas");
  32. }
  33. }
  34. VertexList = vertexList;
  35. OnPopulateMesh(vase);
  36. StartCoroutine
  37. (
  38. Auxiliary.IDelayCall
  39. (
  40. () =>
  41. {
  42. SetVerticesDirty();
  43. },
  44. 2
  45. )
  46. );
  47. }
  48. protected override void OnPopulateMesh(VertexHelper toFill)
  49. {
  50. toFill.Clear();
  51. if (VertexList.Valid() && Draw)
  52. {
  53. toFill.AddVert(VertexList[0]);
  54. toFill.AddVert(VertexList[1]);
  55. toFill.AddVert(VertexList[2]);
  56. toFill.AddVert(VertexList[3]);
  57. toFill.AddTriangle(0, 1, 2);
  58. toFill.AddTriangle(0, 2, 3);
  59. }
  60. }
  61. }