public InputField QJ_Input
int value;
Regex reg = new Regex("^[f0-1]+$");
if (reg.IsMatch(QJ_Input.text))
{
value = Convert.ToSingle(QJ_Input.text);
}
else
{
if (QJ_Input.text == "")
{
QJ_Input.text = "";
}
else
{
QJ_Input.text = QJ_Input.text.Substring(0, QJ_Input[4].text.Length - 1);
}
}
代碼限制了 input輸入得數字隻能是0-1之間,并且隻能輸入一位且隻能是整數類型