fix multiple issues

This commit is contained in:
2026-05-27 07:07:03 +02:00
parent 93a2f0e08c
commit 432dd57d07
12 changed files with 680 additions and 36 deletions
+39
View File
@@ -0,0 +1,39 @@
using TMPro;
using UnityEngine;
public class FloatingWorldText : MonoBehaviour
{
TextMeshPro text;
Vector3 startPosition;
Vector3 offset = new Vector3(0f, 0.6f, 0f);
Color startColor = Color.white;
float duration = 0.75f;
float elapsed;
public void Configure(float fadeDuration, Vector3 moveOffset)
{
duration = Mathf.Max(0.05f, fadeDuration);
offset = moveOffset;
}
void Awake()
{
text = GetComponent<TextMeshPro>();
startPosition = transform.position;
if (text != null)
startColor = text.color;
}
void Update()
{
elapsed += Time.deltaTime;
float t = Mathf.Clamp01(elapsed / duration);
transform.position = Vector3.Lerp(startPosition, startPosition + offset, t);
if (text != null)
text.color = new Color(startColor.r, startColor.g, startColor.b, 1f - t);
if (elapsed >= duration)
Destroy(gameObject);
}
}