球上面數字倒數

 avatar
unknown
c_cpp
3 years ago
855 B
6
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


public class countdown : MonoBehaviour
{
    public timer timer;
    public TextMesh countdown_text;
    float sec = 11;
    public getscore getscore;
    // Start is called before the first frame update
    void Start()
    {
        getscore = GameObject.Find("Score").GetComponent<getscore>();
        timer = GameObject.Find("Time").GetComponent<timer>();
    }

    // Update is called once per frame
    void Update()
    {
        countdown_text.text = ((int)(sec)).ToString();
        sec -= Time.deltaTime;

        if(sec <= 1)
        {
            getscore.Getscore(-3);
            Destroy(gameObject);
        }
        if(timer.IsGameOver)
        {
            Destroy(gameObject);
        }
    }
}
Editor is loading...