::Every time a floating text pops up, this error appears. I wonder if its because its trying to access ‘rect’ variable after destroying the floating text.
<code>IEnumerator GenerarTextoFlotanteCoroutine(string text, Transform target, float duration = 1f, float speed = 1f)
{
GameObject floatingText = new GameObject("Texto Flotante");
RectTransform rectTransform = floatingText.AddComponent<RectTransform>();
TextMeshProUGUI tmPro = floatingText.AddComponent<TextMeshProUGUI>();
tmPro.text = text;
tmPro.horizontalAlignment = HorizontalAlignmentOptions.Center;
tmPro.verticalAlignment = VerticalAlignmentOptions.Middle;
tmPro.fontSize = fontSize;
if (fontFamily) tmPro.font = fontFamily;
rectTransform.position = camaraReferencia.WorldToScreenPoint(target.position);
Destroy(floatingText, duration);
floatingText.transform.SetParent(instancia.damageTextCanvas.transform);
WaitForEndOfFrame wait = new WaitForEndOfFrame();
float time = 0;
float yOffset = 0;
while (time < duration)
{
yield return wait;
time += Time.deltaTime;
tmPro.color = new Color(tmPro.color.r, tmPro.color.g, tmPro.color.b, 1 - time / duration);
yOffset += Time.deltaTime * speed;
rectTransform.position = camaraReferencia.WorldToScreenPoint(target.position + new Vector3(0, yOffset));
}
}</code>