123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- 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<Text>();
- }
- return Text_;
- }
- set { Text_ = value; }
- }
- private Text Text_;
- public bool Draw;
- public List<UIVertex[]> VerticesList;
- #endregion
- public void UpdateStatus(bool draw, VertexHelper empty, List<UIVertex> vertexList)
- {
- Draw = draw;
- if (Draw)
- {
- if (Application.isPlaying)
- {
- if (sprite == null)
- {
- Auxiliary.Instance.DelayCall
- (
- () =>
- {
- sprite = ManaReso.LoadSprite("Atlas", Folder.Atlas);
- },
- 1
- );
- }
- }
- VerticesList = new List<UIVertex[]>();
- 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]);
- }
- }
- }
- }
- }
|