12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- using System.Collections.Generic;
- public class TextPlus : Text
- {
- #region
- public bool Draw;
- private ImagePlus _ImagePlus;
- public ImagePlus ImagePlus
- {
- get
- {
- if (_ImagePlus == null)
- {
- _ImagePlus = GetComponentInChildren<ImagePlus>();
- }
- return _ImagePlus;
- }
- set { _ImagePlus = value; }
- }
- #endregion
- public override void SetVerticesDirty()
- {
- base.SetVerticesDirty();
- int leftIndex = text.IndexOf("<(");
- int rightIndex = text.IndexOf(")>");
- if (leftIndex == -1)
- {
- Draw = false;
- }
- else
- {
- Draw = true;
- ImagePlus.SpriteName = text.Between(leftIndex + 2, rightIndex - 2);
- ImagePlus.StartIndex = leftIndex - 1;
- text = text.Replace(leftIndex, rightIndex, " ");
- }
- }
- protected override void OnPopulateMesh(VertexHelper toFill)
- {
- base.OnPopulateMesh(toFill);
-
- if (Draw)
- {
- Draw = false;
- toFill.GetUIVertexStream(ImagePlus.TextVertexList);
- }
- }
- }
|