LoginSignup
0
0

Unity タイマー

Posted at
c# Scondstimer.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
using UnityEngine.UI;

public class StudyTime : MonoBehaviour
{
    public GameObject timerText;
    private float time=0.0f;
    private int minute=0;

    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        this.time += Time.deltaTime;
        if(this.time<10.0f)
        {
            this.timerText.GetComponent<TextMeshProUGUI>().text =this.time.ToString("F1");

        }
        else
        {
            this.time=10.0f;
            this.timerText.GetComponent<TextMeshProUGUI>().text =this.time.ToString("F1");
            if (Input.GetKeyDown(KeyCode.Return))
            {
                SceneManager.LoadScene("Sccess");
            
            }
        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0