Why does my text look like this?

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;

public class playercontroller : MonoBehaviour
{
public Rigidbody2D playerRB;
public float playerSpeed;
public bool hasKey;
public static playercontroller instance;
public int coins;
public int totalCoins;
public TMP_Text scoreText;
public TMP_Text levelText;
public int level;

public void Awake()
{
    instance = this;
}
// Start is called before the first frame update
void Start()
{
    level = 1;  coins = 0; hasKey = false; totalCoins = 150;
}

// Update is called once per frame
void Update()
{

    playerMovement();
    level = SceneManager.GetActiveScene().buildIndex;
    level = SceneManager.GetActiveScene().buildIndex;
    scoreText.text = "Coins: " + coins.ToString() + "/" + totalCoins.ToString();
    levelText.text = "Level" + SceneManager.GetActiveScene().buildIndex.ToString() + "/" + totalCoins.ToString();
    Debug.Log(coins);



    if (SceneManager.GetActiveScene().buildIndex != 0)
    {

        levelText.text = "Level " + SceneManager.GetActiveScene().buildIndex.ToString();
        Debug.Log(SceneManager.GetActiveScene().buildIndex);

    }
}

private void playerMovement()
{

    if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
    {

        playerRB.velocity = new Vector2(playerRB.velocity.x, playerSpeed);

    }
    else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
    {

        playerRB.velocity = new Vector2(playerRB.velocity.x, -playerSpeed);

    }
    else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
    {

        playerRB.velocity = new Vector2(-1 * (playerSpeed), playerRB.velocity.y);

    }
    else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
    {

        playerRB.velocity = new Vector2(playerSpeed, playerRB.velocity.y);

    }


}
private void OnTriggerEnter2D(Collider2D collision)
{
    if (collision.tag == "portal")
    {
        if (hasKey == true)
        {
            if (coins == totalCoins) {

                if (SceneManager.GetActiveScene().buildIndex == 1) {

                    SceneManager.LoadScene(2);
                    hasKey = false;

                }
                if (SceneManager.GetActiveScene().buildIndex == 2)
                {

                    SceneManager.LoadScene(3);
                    hasKey = false;

                }
                if (SceneManager.GetActiveScene().buildIndex == 3)
                {

                    SceneManager.LoadScene(0);
                    hasKey = false;

                }

            }

        }
    }

    if (collision.tag == "coin")
    {


        audiomanager.instance.playerAudio.PlayOneShot(audiomanager.instance.pickupObjectSFX);

    }
    if (collision.tag == "Death")
    {

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        totalCoins = 150;

    }
}

}

1 Like

IDK

I also want to know why?

Maybe it`s problem with font try to use another