Textmeshpro component is missing

I have two fields in the game, lives and coins, and I can display these values ​​correctly in the game manager. However, the texts are not updated.


    void UpdateUI()
    {
        if (coinText == null || lifeText == null)
        {
            Debug.LogError("CoinText or LifeText is null!");
            return; // Eğer null ise UI güncellenmesini engelle
        }

        coinText.SetText("Coins: " + coins);
        lifeText.SetText("Lives: " + lives);

        Debug.Log("Coins: " + coins + " Lives: " + lives);
        Canvas.ForceUpdateCanvases();
    }

Sounds like you wrote a bug… and that means… time to start debugging!

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume any of your code is even running, it might not be.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.