脚本如下:
using UnityEngine;
using System.Collections;
public class AgeValidation : MonoBehaviour {
private UIInput input;
// Use this for initialization
void Awake () {
input = this.GetComponent<UIInput>();
}
// Update is called once per frame
void Update () {
}
public void AgeChangeValue()
{
int ageValue = int.Parse(input.value);
if (ageValue>100)
{
input.value = "100";
}
else if (ageValue<18)
{
input.value = "18";
}
}
}
网友评论