#if UNITY_EDITOR using Sirenix.OdinInspector; using TMPro; using Unity.Mathematics; using UnityEditor; using UnityEngine; using UnityEngine.UI; namespace UguiToolkit.Editor { public class TextMeshProEntity : BaseEntity { private TextMeshProUGUI m_previewText; public override void ApplyTransform(Transform tf) { var position = ElementInfo.Position; tf.position = StageManager.Instance.PrefabContentsRoot.transform.TransformPoint(new Vector3(position.x, position.y, 0)); tf.rotation = Quaternion.identity; } protected override void OnApplyData(TextMeshProUGUI ui) { ui.text = ElementInfo.text; ui.fontSize = (int)ElementInfo.size; ui.color = ElementInfo.color; ui.alignment = TextAlignmentOptions.Center; 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