ClientServer/Client/Assets/Scripts/UI/CryptoTextPrefixer.cs

25 lines
686 B
C#
Raw Normal View History

2025-09-06 17:17:39 +04:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
[ExecuteAlways]
public class CryptoTextPrefixer : MonoBehaviour
{
//thomas09. This script goes on the Icon Object next to the text!
[Header("Settings")]
[SerializeField] private TMP_Text _text;
[SerializeField] private float _xOffset;
private void LateUpdate()
{
if (_text == null) return;
float textWidth = _text.preferredWidth;
Vector2 textPos = _text.rectTransform.anchoredPosition;
float finalX = textPos.x - textWidth / 2f + _xOffset;
((RectTransform)transform).anchoredPosition = new Vector2(finalX, textPos.y);
}
}