Text only seen in the Inspector

Hy!

I’m making some kind of a board game where you have to collect letters. What I’m trying to do, is to display the collected letters, but it only shows me the first collected letter and after that, the next collected letters are only displayed in the Inspector. I don’t know where my mistake is so any advice is appreciated.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class PlayerController : MonoBehaviour {

    public float speed;
    public UnityEngine.UI.Text LitereColectate;

    private string LitereleMele;
    private Rigidbody rb;
    

    void Start()
    {
       
        rb = GetComponent<Rigidbody>();
        LitereleMele = "";
        LitereColectate.text = "";

    }

    void FixedUpdate()
    {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

        rb.AddForce(movement*speed);
    }

    void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.tag=="Collect")
        {
            other.gameObject.SetActive(false);

            LitereleMele = LitereleMele + other.gameObject.name;
            LitereColectate.text = "Ai colectat: " + LitereleMele;
        }
    }
}

I tried to recreate your problem by first recreating the project: I set up a new project, created 3 spheres (Is Trigger checked), renamed them “A”, “B”, and “C”. I a UI Text GameObject. I created a sphere and added the PlayerController script and attached the UI Text to the script. I played it, touched the 3 cubes, and the UI Text field updated “A”, then “AB”, and then “ABC” as expected. Are you getting different results?

Also, the Inspector doesn’t show any text. Did you mean the Console (also nothing outputted there).

Set your Text's Horizontal Overflow to Overflow