Hi im trying to convert a string into an int and adding an if condition but the condition seems to not trip no matter what i type, thanks.
using UnityEngine;
using TMPro;
using UnityEngine.UIElements;
public class Evasion : MonoBehaviour
{
public TextMeshProUGUI text;
public GameObject[] dormant;
public GameObject[] activated;
public TextMeshProUGUI error;
TextMeshProUGUI the;
void Start()
{
the = error.GetComponent<TextMeshProUGUI>();
foreach (GameObject gameObject in dormant)
{
gameObject.SetActive(true);
}
}
// Update is called once per frame
void Update()
{
}
public void Calculation()
{
int value = System.Convert.ToInt32(text);
if (value<=0 || value>=101)
{
the.text="Please input a valid number";
}
else
{
foreach(GameObject gameObject in dormant)
{
gameObject.SetActive(false);
}
foreach (GameObject gameObject in activated)
{
gameObject.SetActive(true);
}
}
}
}
Possibly "text.text" to get the string out of the TextMeshPro object.
– dstearsOh, i didn´t know the difference, thanks
– Trussmister