这是一款简单的模仿别踩白块的小游戏
Button StartGame;
GameObject StartMenu;
Text text;
bool TimeOpen = false;
float time = 15f;
void Awake()
{
StartGame = GameObject.Find("StartBnt").GetComponent<Button>();
StartMenu = GameObject.Find("StartGame");
text = GameObject.Find("TextTime").GetComponent<Text>();
}
// Use this for initialization
void Start () {
StartGame.onClick.AddListener(StartUI);//button监听UI
}
// Update is called once per frame
void Update () {
CountDown();
}
void StartUI()
{
StartMenu.SetActive(false);//不激活主界面开始场景
TimeOpen = true;
}
public void FinishGamre()
{
}
public void CountDown()
{
if (TimeOpen)
{
time -= Time.deltaTime;
text.text = time.ToString();
}
}
评论