using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; // 文字根据图片填充更新位置 public class TextFollowingFill : MonoBehaviour { public Image progressImage; public float padding = 10f; private RectTransform textLabel; void Start() { textLabel = GetComponent(); } void Update() { float fillAmount = progressImage.fillAmount; float targetX = progressImage.rectTransform.rect.width * fillAmount; textLabel.anchoredPosition = new Vector2(targetX + padding, textLabel.anchoredPosition.y); } }