using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; public class ImagePlus : Image { #region 变量 public Text Text { get { if (Text_ == null) { Text_ = GetComponentInParent(); } return Text_; } set { Text_ = value; } } private Text Text_; public bool Draw; public List VerticesList; #endregion public void UpdateStatus(bool draw, VertexHelper empty, List vertexList) { Draw = draw; if (Draw) { if (Application.isPlaying) { if (sprite == null) { Auxiliary.Instance.DelayCall ( () => { sprite = ResourceManager.LoadSprite("Atlas", Folder.Atlas); }, 1 ); } } VerticesList = new List(); if (vertexList.Valid()) { for (int i = 0; i < vertexList.Count; i += 4) { UIVertex v0 = vertexList[i + 0]; UIVertex v1 = vertexList[i + 1]; UIVertex v2 = vertexList[i + 2]; UIVertex v3 = vertexList[i + 3]; v0.color *= color; v1.color *= color; v2.color *= color; v3.color *= color; VerticesList.Add ( new UIVertex[] { v0, v1, v2, v3 } ); } } OnPopulateMesh(empty); } Auxiliary.Instance.DelayCall ( () => { SetVerticesDirty(); }, 2 ); } protected override void OnPopulateMesh(VertexHelper toFill) { toFill.Clear(); if (Draw) { if (VerticesList.Valid()) { for (int i = 0; i < VerticesList.Count; i++) { toFill.AddUIVertexQuad(VerticesList[i]); } } } } }