How to apply a tween animation to multiple objects. (optimization)

554 Views Asked by At

I'm using DoTween to animate floating text in Unity. All floating text has simple, one same animation. Codes goes like

public void FloatText(Vector3 pos, int value)
    {
        var obj = textObjQueue.Dequeue();
        obj.SetActive(true);
        obj.transform.position = pos;
        obj.GetComponent<TextMeshProUGUI>().text = value.ToString();
        TweenText(obj);
    }

    void TweenText(GameObject obj)
    {
        obj.transform.DOMoveY(pos+Vector3.up, .2f).OnComplete(() => PoolObj(obj));
    }

All floating texts should be played in different place and time, but has same animation- moving upside from their original position. Literally there are tons of floating text played(50 per second I guess), and I want to know if there are any technique to reduce its cost. Any helps would be great. Thanks in advance :-)

0

There are 0 best solutions below