123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TemplateText : BaseTemPlate
- {
- private RectTransform m_Canvas;
- private Image m_BG;
- private Text m_Text;
- private float m_CanvasHeight;
- public float CanvasHeight
- {
- get { return m_CanvasHeight; }
- set
- {
- m_CanvasHeight = value;
- m_Canvas.sizeDelta = new Vector2(m_Canvas.sizeDelta.x, value);
- }
- }
- private float m_CanvasWidth;
- public float CanvasWidth
- {
- get { return m_CanvasWidth; }
- set
- {
- m_CanvasWidth = value;
- m_Canvas.sizeDelta = new Vector2(m_CanvasWidth, CanvasHeight);
- }
- }
- protected override void OnEnable()
- {
- base.OnEnable();
- if (GameManager.Instance.IsRuning && m_Text.text == null)
- {
- m_Text.text = SuCaiData.textContent;
- m_BG.sprite = ResMgr.Instance.Load<Sprite>("Template/Texture/文本框" + SuCaiData.TextBJ.ToString());
- }
- }
- protected override void OnAwake()
- {
- base.OnAwake();
- m_Canvas = transform.Find("Canvas").GetComponent<RectTransform>();
- m_BG = transform.Find("Canvas/Image").GetComponent<Image>();
- m_Text = transform.Find("Canvas/Text").GetComponent<Text>();
- HideCollider();
- }
- private void Update()
- {
- CanvasHeight = m_Text.GetComponent<RectTransform>().sizeDelta.y + 60;
- }
- public override void SetData(MaterialObjValue value, int updateTime)
- {
- base.SetData(value, updateTime);
- SuCaiData = value;
- Data = new DownloadData(value);
- Data.updateTime = updateTime;
- if (string.IsNullOrWhiteSpace(value.textContent))
- {
- return;
- }
- m_Text.text = value.textContent;
- m_BG.sprite = ResMgr.Instance.Load<Sprite>("Template/Texture/文本框" + value.TextBJ.ToString());
- }
- public override void HideCollider()
- {
- base.HideCollider();
- }
- }
|