I tried converting a string to an int using
System.Convert.ToInt32(text)
but it didn’t work, thanks.
using UnityEngine;
using TMPro;
using UnityEngine.UIElements;
public class Evasion : MonoBehaviour
{
public TextMeshProUGUI Text;
public GameObject[] dormant;
public GameObject[] activated;
public TextMeshProUGUI error;
private string text;
void Start()
{
error.GetComponent<TextMeshProUGUI>();
foreach (GameObject gameObject in dormant)
{
gameObject.SetActive(true);
}
}
// Update is called once per frame
void Update()
{
}
public void Calculation()
{
text=Text.text;
int value = System.Convert.ToInt32(text);
if (value<=0 || value>=101)
{
error.text="Invaild";
}
else
{
foreach(GameObject gameObject in dormant)
{
gameObject.SetActive(false);
}
foreach (GameObject gameObject in activated)
{
gameObject.SetActive(true);
}
}
}
}
You have to supply more information other than "it didn't work"
– ArachnidAnimal