12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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)
- {
- sprite = Bundle.Atlas.LoadAsset<Sprite>("Atlas");
- }
- }
- VerticesList = new List<UIVertex[]>();
- for (int i = 0; i < vertexList.Count; i += 4)
- {
- VerticesList.Add
- (
- new UIVertex[]
- {
- vertexList[i + 0],
- vertexList[i + 1],
- vertexList[i + 2],
- vertexList[i + 3],
- }
- );
- }
- OnPopulateMesh(empty);
- StartCoroutine
- (
- Auxiliary.IDelayCall
- (
- () =>
- {
- 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]);
- }
- }
- }
- }
- }
|