How do I translate integers and strings into objects?

Right now, I’m making a game that has a scoring system. Although I got the scoring system to work, how do you get the game’s built-in assets, such as text objects, to read the stored integers and strings? I need this to read the scores.

What you mean is display score in an UI Text Component, right? If that’s what you meant, you can use this code right here:

If you are using Unity’s built in UI Text, you can use this code:

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

public class Example : MonoBehaviour
{
    //UI Text
    public Text display;

    private string info1 = "Results:";
    private int info2 = 30;

    private void Update()
    {
        //The UI Text will show "Results: 30"
        display.text = info1 + " " + info2;
    }
}

And if you’re using TMP (Text Mesh Pro):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class Example : MonoBehaviour
{
    //UI TMP Text
    public TMP_Text display;

    private string info1 = "Results:";
    private int info2 = 30;

    private void Update()
    {
        //The UI Text will show "Results: 30"
        display.text = info1 + " " + info2;
    }
}

Hope this helps :slight_smile: