V
V
Vladimir Kulikov2020-04-25 13:48:16
Unity
Vladimir Kulikov, 2020-04-25 13:48:16

How to convert a string to a number in Unity?

using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI; // для работы с UI
using UnityEngine;

public class button : MonoBehaviour
{
    public int      mega_number = 0;
    public GameObject guiTextLink; //Ссылка на объект, если скрипт не на нем
    // Start is called before the first frame update
    void Start(){
        
    }

    // Update is called once per frame
    void Update(){
        mega_number++;
        print(mega_number);
        guiTextLink.GetComponent<Text>().text = mega_number;
    }
}


Good afternoon, the unit swears at this line: guiTextLink.GetComponent().text = mega_number;

How can I make this line expect a number and not a string?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-04-25
@it_proger29

mega_number.ToString()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question