#if UNITY_EDITOR using System.Collections; using System.Collections.Generic; using UguiToolkit.Editor; using UnityEngine; using UnityEngine.UI; public class TextEntity : BaseEntity { private Text m_previewText; protected override void OnApplyData(Text ui) { ui.text = ElementInfo.text; ui.fontSize = (int)ElementInfo.size; ui.color = ElementInfo.color; ui.alignment = TextAnchor.MiddleCenter; var rectTransform = ui.rectTransform; rectTransform.sizeDelta = new Vector2(ElementInfo.w + 10, ElementInfo.h + 10); } public void InitPreviewText() { if (ElementInfo == null) return; if (!TryGetComponent(out m_previewText)) { m_previewText = gameObject.AddComponent(); } OnApplyData(m_previewText); ApplyTransform(transform); } } #endif